Can poll_read() cause a hanging FIN_WAIT2 state in a tcp connection? #7037
Unanswered
vinny-pereira
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I am new to rust development and tokio. I am currently trying to solve an issue within another project, where, sometimes if that program runs for a long time, some of its sockets will linger indefinitely in a FIN_WAIT2 state.
As far as I understand, that state will linger because we shutdown our write side of the socket, we received an ACK from the peer and we are waiting for their FIN so we can close our reader.
Currently this is the loop we use for our read half, where we call
run()
in a spawned task:If something goes wrong with the network, if the implementation of the peer is not properly set, we might never receive a message again from that peer.
My question here is, in this case, would the
read_exact()
call be hanging forever in this situation? there is no timeout enforced here, as I read inpoll_read
, if no message is received, poll_read() will be kept in a Pending state until an actual message is received. If we don't receive a message, we won't get the output of that future.Is my chain of thought correct here? Would that be a indicative of why the FIN_WAIT2 might arise sometimes? because if that's true, the reader half won't ever be dropped keeping the connection opened.
Also, would a CancellationToken work in this situation at the task spawn? or would a timeout be more suitable here?
EDIT: This is happening on Linux machines only at the moment, at least this behaviour was reported from Linux users only
Beta Was this translation helpful? Give feedback.
All reactions