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

Leaving and then rejoining a room often causes: "Uncaught Error: Connection failed." #71

Open
rogersanick opened this issue May 5, 2024 · 1 comment

Comments

@rogersanick
Copy link

As mentioned in the title, I have a utility function that allows users to 'refresh' a room when experiencing connectivity issues. This is the function code:

  const refreshRoom = useCallback((roomId: string) => {
    const room = rooms[roomId];
    removeRoom(roomId);
    room.leave();
    joinTrysteroRoom(roomId);
  }, [joinTrysteroRoom, rooms]);

and this is the error for the caller:

events.js:139 Uncaught Error: Connection failed.
    at Peer._onConnectionStateChange (index.js:699:28)
    at Peer._pc.onconnectionstatechange (index.js:118:12)

and the recipient

events.js:139 Uncaught Error: Connection failed.
    at Peer._onConnectionStateChange (index.js:699:28)
    at Peer._pc.onconnectionstatechange (index.js:118:12)
_onConnectionStateChange @ index.js:699
Peer._pc.onconnectionstatechange @ index.js:118
Show 2 more frames
Show less
2index.js:184 Uncaught (in promise) Error: cannot signal after peer is destroyed
    at Peer.signal (index.js:184:39)
    at WebSocket.eval (nostr.js:179:26)
signal @ index.js:184
eval @ nostr.js:179
Show 2 more frames
Show less
3events.js:139 Uncaught Error: Connection failed.
    at Peer._onConnectionStateChange (index.js:699:28)

In this case I'm running the sender / receiver locally. Both on chrome.

@jeremyckahn
Copy link
Contributor

Does introducing a wait time (5 seconds, for example) between disconnection/reconnection help? I'm able to induce similar behavior manually in my own apps and it seems to work well enough. I'm thinking that the synchronous nature of the operation as it's implemented in your refreshRoom code may not be allowing the libraries and/or browser enough time to refresh things.

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

2 participants