ChainSafe / js-libp2p-yamux

Typescript implementation of Yamux
Other
12 stars 9 forks source link

KeepAlive Functionality #76

Open justin0mcateer opened 5 months ago

justin0mcateer commented 5 months ago

What is the intended function of the keepAlive functionality? Is it intended to only send pings blindly with no regard for the outcome? The keepAlive logic doesn't appear to close the stream or emit any event on ping failures. It doesn't appear to track the number of ping failures.

We are having issues with WebSockets staying open for long periods of time when the other side has failed/stopped uncleanly. We have keepAlive enabled and the interval set to 27 seconds.

To overcome this, we have implemented a periodic ping at the application layer, using the Ping protocol, and we track the number of failed connections and force the connection closed if necessary. However, this is fairly complex thing to manage at the application level and it seems like the keepAlive functionality in the muxer might be a more sensible place for this functionality.

achingbrain commented 3 months ago

KeepAlive is not mentioned in the Yamux spec but looking a the implementation if the keepalive ping fails the connection should be closed.

It looks like we just ignore any keepalive faliures here which is probably incorrect.