Skip to content

Connection is not shutting down properly, which makes reconnects within ~10 seconds impossible #1835

@marcus-pousette

Description

@marcus-pousette

I noticed an issue when I have to nodes in two browser tabs, and I refresh on of the tabs. The connection is able to resume immediately, but

  1. After a few seconds the WebRTC connection closes in the tab that did not refresh (even though the client in both tabs are live and connected)
  2. The tab that refreshes still thinks the connection is live which makes messages not delivering

To reproduce the issues partially:

Put a log here
https://github.com/libp2p/js-libp2p-webrtc/blob/efe5ce70bdffdb67c237cfb4688afd562528a050/src/maconn.ts#LL68C9-L68C9

and run the browser-to-browser example.

Node 1 connects to the relay, and Node 2 connects to Node 1 relayed address.

After connection, close Node 2 and observe that the state change does not appear immediately in the logs.

--

If Node 2 would restart with the same PeerId and connects to Node 1 before the state change has happened, Node 1 will terminate Node 2 wrongfully as

https://github.com/libp2p/js-libp2p-webrtc/blob/efe5ce70bdffdb67c237cfb4688afd562528a050/src/maconn.ts#L70

will bubble up.

Since the browser-to-browser example is using new PeerIds each time the issue becomes less severe, but in real world scenarios where you run nodes with the same PeerId you will have nodes running with broken connections, as one side of the connection has wrongfully terminated it due to the reason outlined above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    🎉Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions