-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bufio: textproto's bufio design causes half closed idle connections on TCP connection closed by a remote server #53930
Comments
The CLOSE-WAIT is from your client never closing the connection. I don't see anything to do here. |
@seankhliao thanks for your reply. Nevertheless I disagree with you. Without bufio it is quite easy to detect that the connection is closed. But with bufio you always need to |
The socket API does not provide any mechanism for detecting that a TCP socket is closed without reading from it. |
@seankhliao generally they are quite similar, they both use textproto wrapped around bufio. And you can see that http transport implementation peeks bufio in a loop ( @ianlancetaylor, my aim is to avoid reinventing the wheel and have a general implementation to detect a closed connection. |
@kayrus If you can find a general mechanism, then, great. I don't know of one. |
with my latest change to go-smtp where I'm checking for a connection + buffering what is read + write the buffer down the test looks better: the connection is closed. the recent test (see https://gist.github.com/kayrus/31023f2a1cc30b1744b3c45cd3557d21) closes the connection properly. I'm sure that the similar logic can be done in bufio. @ianlancetaylor what do you think? |
Long living (e.g. keepalive, connection reuse) textproto client connections don't get an event when a remote server closes a connection causing
CLOSE_WAIT
half closed TCP connections on the client side.See an example: https://gist.github.com/kayrus/31023f2a1cc30b1744b3c45cd3557d21
I see that for an HTTP client go lang has a workaround. IMHO this solution is too complicated and I wonder whether it's possible to implement something general and reuse it for HTTP/SMTP/etc.
see also emersion/go-smtp#185
The text was updated successfully, but these errors were encountered: