Repository navigation
Add events for received PING/PONG messages #36
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we verify that the pong-payload is the same as what we sent earlier with
ping(payload)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would require storing the payload of every PING message. Can we even rely on the ordering of the PONGs vs PINGs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From RFC6455:
But it is also allowed to send PONGs, without receiving a PING first.
Yes, I think we should store the ping payload, and verify it against the first pong we receive, and the reset it to None (or similar?).
If we want to overcomplicate this, we should introduce a stack that holds all ping-payloads, and we pop them off one-by-one for every pong received...
For now, I would just clearly document that every
ping(payload)overwrites the "global" expected pong response payload. So, don't send a PING before you got the PONG of the last one back.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we definitely can't verify the payload. RFC 6455 says:
So if we get a Pong frame with an unexpected payload, we have no way to know whether that's because the peer screwed up the payload, or because they just happened to spontaneously send us a weird Pong and the one we're expecting will be along any moment. So even if we stored the payload, we couldn't do anything with that information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the protocol lets either side send PONGs arbitrarily, how do we know that a particular PONG was a response to a PING that we sent?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, arguably this is difficult. I couldn't find any errata in the RFC (yet).
IMO this sentence in the RFC is pretty clear:
Strangely it doesn't make use of the usual "MUST HAVE" in capital letters to indicate an absolute requirement / condition...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RFC 6455 is generally pretty clear about what invariants it wants implementors to enforce on their peers. There are lots of cases where it says "if your peer does this, you MUST immediately close the connection". This isn't one of them, and my guess is that this is intentional (even if the lack of all-caps might be accidental), because, well, AFAICT it's literally impossible to enforce even if we want to :-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my quick stack idea might work.
But I agree that this is too complicated.
I propose to ignore the payload verification in wsproto, and clearly document that it is the users responsibility to compare the payloads (if it is important to their use case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you propose that even the users would accomplish that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to give a solution... 😄
Sounds terrible, but it is what it is.