Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ice connection failure error randomly after successful connection and data exchange. #886

Open
Swayam-Shree opened this issue Apr 27, 2022 · 0 comments

Comments

@Swayam-Shree
Copy link

Swayam-Shree commented Apr 27, 2022

simple-peer v9.11.1

windows 10, node.js v16.15.0, npm v8.5.5

What happened?
Using socket.io, I connect multiple client peers to my game server peer. Everything works as expected but I randomly get an "ERR_ICE_CONNECTION_FAILURE". I found this issue202 and have tried all the troubleshooting tips but none solved the error. One thing to note is that in issue202, the error comes up right during connection of peers, but for my case, the peers work perfectly for some time and then the error pops up randomly.

I have not been able to isolate the cause for the error, sometimes it happens when the server is idle, other times it happens when clients are regularly connecting and disconnecting. Occasionally the error does not pop up when the server is left overnight, but generally it occurs within 10 or so minutes.

This only comes up server side on nodes.js and not client side. I am also using webpack btw.

Some minimal code to show usage:

socket.on("serverHostRequest", (name, room, remoteSdp, signalLocalSdp) => {
        let peer = new Peer({ wrtc: wrtc });

        peer.signal(remoteSdp);
        peer.on("signal", (localSdp) => {
            signalLocalSdp(localSdp);
        });
        peer.on("connect", () => {
            peer.client = {
                loggedIn: true,
                position: {
                    _dirty: true,
                    value: [0, 0, 0]
                },
            };
        });
        peer.on("data", (data) => {
            data = JSON.parse(data.toString());

            switch(data.type) {
                case "position":
                    let position = peer.client.position;
                    position._dirty = true;
                    position.value = data.position;
            }
        });

        socket.peer = peer;
    });

And this function is called at a high frequency, for all the peers

if (socket.peer && socket.peer.client && socket.peer.client.loggedIn) {
    socket.peer.send(JSON.stringify({
        type: "position",
        value: positions
    }));
}

this is the error:

QAiZs

What did you expect to happen?
According to error, I suppose it should only happen during the initiation of the connection and not when connection has already been established. If so it might indicate that the error comes up during reconnection. If the connection was successful initially, then I suppose there should not be a problem on reconnection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant