Fix random disconnect after upgrade to encrypted#253
Merged
ikalchev merged 1 commit intoikalchev:devfrom May 15, 2020
Merged
Conversation
After server restarts accessories would sometimes go unavailable because after reconnecting and switching to encrypted transport part of the unencrypted response would not have been sent down the wire. After the upgrade to encrypted happens that response gets lost which means the server starts sending encrypted data when the hap client/controller is still expecting to finish reading the unencrypted data. The net result is that the controller/client has to try again to get another connection to the server where it does not get unluckly and hit this race condition. Before the change "Cleaning connection" was very common in the log. Its now rare. Now that Apple has published more information, we can improve conformance to HAP spec. Content-Length is no longer sent on empty content as it could lead to a loop on the client/controlller side The Connection, Date, and Server headers are not expected to be sent according to the spec, and they are now suppressed.
Contributor
Author
|
Manual Testing steps: Turn on airplane mode, turn off wifi, wait for accessories to go unavailable. Turn back on wifi and airplane mode off. Watch the log. Verify no double connects |
Codecov Report
@@ Coverage Diff @@
## dev #253 +/- ##
==========================================
+ Coverage 62.96% 63.10% +0.14%
==========================================
Files 16 16
Lines 1736 1743 +7
Branches 186 187 +1
==========================================
+ Hits 1093 1100 +7
Misses 591 591
Partials 52 52
|
Owner
|
Great job! |
This was referenced May 26, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
After server restarts accessories would sometimes go
unavailable because after reconnecting and switching
to encrypted transport part of the unencrypted response
would not have been sent down the wire. After the
upgrade to encrypted happens that response gets lost
which means the server starts sending encrypted data
when the hap client/controller is still expecting
to finish reading the unencrypted data.
The net result is that the controller/client has to
try again to get another connection to the server
where it does not get unluckly and hit this race
condition.
Before the change "Cleaning connection" was
very common in the log. Its now rare.
Now that Apple has published more information,
we can improve conformance to HAP spec.
Content-Length is no longer sent on empty content
as it could lead to a loop on the client/controller side
The Connection, Date, and Server headers are not expected to be
sent according to the spec, and they are now suppressed.