feross / feross/simple-peer

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

Open
#886 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.8k
Forks
983
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/feross/simple-peer/issues/202) 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](https://user-images.githubusercontent.com/61933177/165447374-8a8dc61b-3e26-4ee9-a5bf-3532a256026b.png)

**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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.