Fix TLS socket read stall immediately after handshake #2461
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I ran in to an issue with http4s ember servers where JRE HttpsURLConnection clients would stall occasionally. The TLS handshake would complete but ember server would timeout while reading the request body, eventually resulting in a 500 response indicating a request timeout.
The issue was caused by unwrapped data remaining in the
unwrapBuffer
after the handshake completed. As a result, the request to read from the TLS socket would result in an underlying read on the raw socket, but there's no further data available, and hence the read would timeout.I tried reproducing in a test in fs2-io but due to various timing and buffer sizing sensitivities, I was unsuccessful. I have confirmed a fix using this http4s test though: https://gist.github.com/mpilquist/82726e0f8ff740defca6a235bf3efd41