fix(nvhttp): wrap TLS socket to ensure graceful closure #3077
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.
Description
The upstream
SimpleWeb::Server<SimpleWeb::HTTPS>
implementation doesn't ensure the TLS session is torn down gracefully which leads to unexpected TCP RST packets from Sunshine to the client when using TLS v1.3 and settingclose_connection_after_response
(which NvHTTP does). Depending on the client, this spurious TCP RST can lead to the HTTPS request failing even though all the required data did end up on the wire. TheQSslSocket
implementation in Qt seems to be particularly susceptible to the issue, causing computers to constantly bounce between online and offline.Ideally this would be fixed upstream, but the way that the classes are structured with
SimpleWeb::ServerBase
doesn't provide a straightforward place to insert this code (ServerBase
has no clue about any TLS stuff). Fixing it on our side using a little wrapper class is fairly simple with most of the diff just being renames of the old class to the new one. We already had a class derived fromSimpleWeb::Server<SimpleWeb::HTTPS>
, so changing it to derive fromSimpleWeb::ServerBase
just required a few more lines from the upstream constructor ofSimpleWeb::Server<SimpleWeb::HTTPS>
.Screenshot
Issues Fixed or Closed
Type of Change
.github/...
)Checklist