I have been learning how to use the simple-peer module to implement WebRTC protocal in a call app, using React , Vite I am having this problem,this warning:
simple-peer.js?v=76ad0f10:2833 Module "util" has been externalized for browser compatibility. Cannot access "util.inspect" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
as well as this error:
Uncaught Error: Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11
Perticularly when I try to run this line:
const peer= new Peer({initiator:false,trickle:false,stream:stream})
The whole function:
function acceptCall() {
setCallAccepted(true)
const peer= new Peer({initiator:false,trickle:false,stream:stream})
peer.on('signal',data=>{
// socket.emit('acceptCall',{signal:data,to:caller})
console.log("Accepting call: signal for the caller",{signal:data})
})
peer.on('stream',stream=>{
partnerVideo.current.srcObject=stream
})
//Setting callers signal
peer.signal(callerSignal)
}
Iv tried updating chrome and using IE11,
Seems the error is for vite, using npx to create the react app seems to work: