Skip to content
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

crypto/tls.Conn.Close can block indefinitely #41340

yahe opened this issue Sep 11, 2020 · 2 comments

crypto/tls.Conn.Close can block indefinitely #41340

yahe opened this issue Sep 11, 2020 · 2 comments


Copy link

@yahe yahe commented Sep 11, 2020

What version of Go are you using (go version)?

$ go version
go version go1.13.1 darwin/amd64

Does this issue reproduce with the latest release?


What operating system and processor architecture are you using (go env)?

macOS 10.14.6 (18G6020)

What did you do?

Call Close() on a tls.Conn

What did you expect to see?

The call to Close() to not block, or documentation on the observed behavior

What did you see instead?

Rarely, Close() hangs indefinitely unless I also set a write deadline on the connection.

It's understandable as the TLS conn tries to send a close alert before closing the connection, but it's not clearly stated in the docs, and I wrongly assumed tls.Conn to have the same behavior as the underlying connection. As far as I can tell tls.Conn is the only type to implement the net.Conn interface in the std library to require a wrote deadline not to let Close block indefinitely. Afaict Read has the same "issue" in that it automagically performs the handshake first, with the aggravating factor that having to set a write deadline not to let Read block is even more unintuitive.

Copy link

@networkimprov networkimprov commented Sep 11, 2020

This is #31224, which has been passed over in the last two releases :-(

Copy link

@davecheney davecheney commented Sep 12, 2020

Duplicate of #31224

@davecheney davecheney marked this as a duplicate of #31224 Sep 12, 2020
@davecheney davecheney closed this Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.