libp2p / py-libp2p

The Python implementation of the libp2p networking stack 🐍 [under development]
https://libp2p.io
Other
478 stars 106 forks source link

Patch up disconnect on `mplex` #416

Open ralexstokes opened 4 years ago

ralexstokes commented 4 years ago

Reliably see this when using mplex when a remote peer disconnects (possibly w/o warning):

DEBUG mplex unavailable while waiting for incoming: failed to read the header correctly from the underlying connection: {'requested_count': 2, 'received_count': 0}
ralexstokes commented 4 years ago

Seeing a related exception where I think there is some incorrect channel accounting in mplex.

End result is a MplexStreamReset that raises a StreamReset and this takes down the entire libp2p.Host.

Any individual peer failure should not disrupt the function of the host...

ralexstokes commented 4 years ago

There seems to be race between our set of peers and the pubsub machinery.

If a peer disconnects at the right time (which seems to be when pubsub is iterating through peers to send messages to), the peers dictionary is changed, which raises an iterator exception.