feross / simple-peer

📡 Simple WebRTC video, voice, and data channels
MIT License
7.44k stars 975 forks source link

Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11 #925

Closed gateremark closed 9 months ago

gateremark commented 10 months ago

What version of this package are you using? Version 9.11.1

What operating system, Node.js, and npm version? Using Linux (Ubuntu), pnpm package manager

What happened? I am using the Chrome browser and on clicking 'Call' button on my web app, I get the error logged on the Chrome browser console.

Screenshot from 2023-12-29 21-05-53

<button
    className="bg-[#ffffff] text-[#000000] p-2 m-2 rounded-md"
// Options.jsx:47 (Line below)
    onClick={() => callUser(idToCall)}
>
    Call
</button>
    const callUser = (id) => {
        if (!stream) {
            console.log("Stream is undefined");
            return;
        }
// SocketContext.jsx:67 (Line below)
        const peer = new Peer({ initiator: true, trickle: false, stream });

        peer.on("signal", (data) => {
            socket.emit("callUser", {
                userToCall: id,
                signalData: data,
                from: me,
                name,
            });
        });

        peer.on("stream", (currentStream) => {
            if (userVideo.current) {
                userVideo.current.srcObject = currentStream;
            }
        });

        socket.on("callAccepted", (signal) => {
            setCallAccepted(true);

            peer.signal(signal);
        });

        connectionRef.current = peer;
    };
AleemIlyas commented 9 months ago

Did you found the solution ?

AleemIlyas commented 9 months ago

I found the solution of this you need to make a samll change in randombyte you need to change

const crypto = crypto || msCrypto

with

const _global = typeof globalThis !== 'undefined' ? globalThis : global const crypto = _global.crypto || _global.msCrypto

This issue is fixed in randombyte repository but package is still not updated

gateremark commented 9 months ago

Awesome, lemme check it out