Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Peers get disconnected when signalling server is stopped #453

Closed
BaptisteHubert opened this issue Jul 1, 2022 · 4 comments · Fixed by #456
Closed

Peers get disconnected when signalling server is stopped #453

BaptisteHubert opened this issue Jul 1, 2022 · 4 comments · Fixed by #456
Labels
kind/bug A bug in existing code (including security flaws) released

Comments

@BaptisteHubert
Copy link

  • Version of libp2p: 0.37.3
  • Version of webrtc-star: 3.0.0
  • Platform: Windows [10 - 10.0.19044](callto:10 - 10.0.19044) Build 19044 and Chrome and Opera (respectively v103.0.5060.66 and 88.0.4412.53)

Severity: High

Description:

We are trying to create a peer-to-peer web application using libp2p to enable browsers to communicate.
As such, we used the example named libp2p-in-the-browser as a starting point.
In this example, peers discover and connect to each others using provided webrtc-star signalling servers and bootstrap nodes.

In order to setup our own network, we use our own webrtc-star signalling server and do not use bootstrap nodes anymore.
In this configuration, we discovered that peers get disconnected if the signalling server is shutdown afterward.

Following what is explained regarding the network topology in this issue, we thought that browsers were communicating directly with each others using webrtc channels once the network is setup.
As such, we thought that the webrtc-star signalling server was not required anymore once peers were connected.

We were able to reproduce this issue with the latest versions of libp2p and webrtc-star.

In order to find potential issues in our code, we tried projects from the community, notably https://github.com/svdo/js-libp2p-example-chat-in-the-browser.
This project used former versions of libp2p (0.27.7) and webrtc-star (0.17.3).
We edited its code to use our own signalling server and disable discovery using bootstrap nodes.
This time, nodes were still connected and able to communicate when we shutdown the signalling server.

It thus appears that some changes from these versions to nowadays made the signalling server the center and the single point of failure of the network topology.

Steps to reproduce the error:

The following repository provides the code and instructions to reproduce the issue: https://github.com/BaptisteHubert/libp2p-webrtc-star-issue.

@BaptisteHubert
Copy link
Author

I'm still blocked by this problem, would you have any pointer as to how to solve this @achingbrain ?

@BaptisteHubert BaptisteHubert changed the title [Bug] Peers get disconnected when signalling server is stopped Peers get disconnected when signalling server is stopped Jul 12, 2022
@achingbrain
Copy link
Member

I've done a little digging into this, it looks like we receive an error event when the signalling server goes away, which then causes us to close the listener and tear down the connections.

It should be more fault tolerant - if the signalling server disconnects the listener should:

a) try to reconnect
b) error we try to dial a new peer before reconnecting succeeds
c) not cause existing connections to be closed

@achingbrain achingbrain added the kind/bug A bug in existing code (including security flaws) label Jul 13, 2022
achingbrain added a commit that referenced this issue Jul 13, 2022
Tweaks the logic around server errors so that if we lose our connection
to the sigserver, we now let socket.io's reconnection logic handle
trying to reconnect instead of tearing everything down.

Fixes: #453
github-actions bot pushed a commit that referenced this issue Sep 21, 2022
## [@libp2p/webrtc-star-signalling-server-v2.0.4](https://github.com/libp2p/js-libp2p-webrtc-star/compare/@libp2p/webrtc-star-signalling-server-v2.0.3...@libp2p/webrtc-star-signalling-server-v2.0.4) (2022-09-21)

### Bug Fixes

* do not close connections when sigserver goes away ([#456](#456)) ([206bdd5](206bdd5)), closes [#453](#453)
@github-actions
Copy link

🎉 This issue has been resolved in version @libp2p/webrtc-star-signalling-server-v2.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this issue Sep 21, 2022
## [@libp2p/webrtc-star-v3.0.2](https://github.com/libp2p/js-libp2p-webrtc-star/compare/@libp2p/webrtc-star-v3.0.1...@libp2p/webrtc-star-v3.0.2) (2022-09-21)

### Bug Fixes

* do not close connections when sigserver goes away ([#456](#456)) ([206bdd5](206bdd5)), closes [#453](#453)
@github-actions
Copy link

🎉 This issue has been resolved in version @libp2p/webrtc-star-v3.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tinytb tinytb moved this to Done in js-libp2p Oct 11, 2022
@tinytb tinytb added this to js-libp2p Oct 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug A bug in existing code (including security flaws) released
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants