[maybe solved] Go-yamux: signaling to the remote that the stream is closed

It seems that when Close() is called on a stream with go-yamux, it’s possible that the remote does not immediately realize the stream has been closed.

I’m not running into this issue anymore now that I changed the behavior of my app to not rely on the Close notification going through to signal done, but I wonder if this could lead to streams leaking / being left unclosed on one end of the connection.

There are a few other things that can be improved a bit, probably:

  • Atomic integers can be updated to use the new atomic.Int64
  • Is the rtt measurement / window size goroutine necessary? (Can’t we spin off a goroutine to measure it periodically when Read is called?)
  • 3 goroutines for every session - see above

Hopefully I can send some PRs soon for this.

1 Like

After adding some debug messages:

[P1] [DEBUG] yamux: registered new outgoing stream: 4 
[P2] [DEBUG] yamux: registered new incoming stream: 4

# Close() called on P2
[P2] [DEBUG] yamux: deleted stream: 4
[P2] [WARN] yamux: Discarding data for stream: 4

So: after calling CloseSend followed by Close (a second later) on P2, P1 still thinks the stream is open

1 Like

Hey, I receive annoying [WARN] yamux: Discarding data for stream messages in my logs, did you manage to get rid of them? AFAIK they come from Identify service.

Which implementation of libp2p are you using?

I use go-libp2p. ______

For technical questions, you’ll probably get a better response if you ask in the technical forum on Github: libp2p/go-libp2p · Discussions · GitHub