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

App-level websocket pongs. #561

Merged
merged 6 commits into from
Jan 20, 2019
Merged

App-level websocket pongs. #561

merged 6 commits into from
Jan 20, 2019

Conversation

fisx
Copy link
Contributor

@fisx fisx commented Jan 7, 2019

Fixes #560.

@marcoconti83 this needs to be ok'ed by all clients, since it generates web socket messages that need to be handled by the clients. More complicated solutions are conceivable, like a way for the client to turn this on or off (but I'm not in favour of that).

I also wonder if there is really no other way for client to tell whether the browser has lost the websocket connection, but I am ready to believe that's the case.

tasks:

  • send app-level pongs
  • integration test

neongreen
neongreen previously approved these changes Jan 7, 2019
_ -> reset counter s 0 >> loop
_ -> do
reset counter s 0
sendAppLevelPong
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel slightly uneasy about sending a pong for every data message – perhaps we should only pong to messages that say "ping"? Though I can't see any actual problems with sending a pong for every data message.

I also feel uneasy about sending and receiving payloads that are not Protobuf/JSON-encoded (or generally encoded in the same way as other payloads), but dragging Protobuf into this code looks like a mistake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel slightly uneasy about sending a pong for every data message – perhaps we should only pong to messages that say "ping"? Though I can't see any actual problems with sending a pong for every data message.

the reason i chose to ignore the ping message is that it is currently a rather ad hoc string, and i think it's brittle and dangerous to depend on that. note that we don't expect any other messages but ping; everything else from the client is sent via http. (right?)

I also feel uneasy about sending and receiving payloads that are not Protobuf/JSON-encoded (or generally encoded in the same way as other payloads), but dragging Protobuf into this code looks like a mistake.

i'm indifferent. let's look into protobuffing it once it's clear what we want to do. I still hope there is a way to avoid this PR entirely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still hope there is a way to avoid this PR entirely.

Agreed.

@neongreen neongreen dismissed their stale review January 7, 2019 13:34

Dismissing my review because there's still a future integration test to be reviewed.

neongreen
neongreen previously approved these changes Jan 8, 2019
@fisx fisx force-pushed the fisx-app-level-websocket-pongs branch from b9c99a4 to a8fd6ba Compare January 8, 2019 16:45
@fisx fisx dismissed neongreen’s stale review January 8, 2019 16:46

thanks, but ti's not done yet! :-)

@fisx
Copy link
Contributor Author

fisx commented Jan 8, 2019

17c189a fails, a8fd6ba passes. needs more thinking...

@fisx fisx changed the title App-level websocket pongs. [WIP] App-level websocket pongs. Jan 17, 2019
@fisx fisx force-pushed the fisx-app-level-websocket-pongs branch from a8fd6ba to 17c189a Compare January 17, 2019 10:58
@fisx fisx changed the title [WIP] App-level websocket pongs. App-level websocket pongs. Jan 17, 2019
@fisx
Copy link
Contributor Author

fisx commented Jan 17, 2019

17c189a fails, a8fd6ba passes. needs more thinking...

could not reproduce. perhaps it's related to #573 (comment) ?

@fisx fisx requested a review from neongreen January 18, 2019 14:31
WS.receiveData conn >>= atomically . writeTChan chread
h2 <- async . forever $ do
WS.sendTextData conn =<< atomically (readTChan chwrite)
wait h1 >> wait h2 -- one way of saying "don't die!"
Copy link
Contributor

@neongreen neongreen Jan 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems nicer to use concurrently_:

wsReaderWriter = 
    concurrently_
        (forever $ WS.receiveData conn >>= atomically . writeTChan chread)
        (forever $ WS.sendTextData conn =<< atomically (readTChan chwrite))

@fisx fisx merged commit a8efaed into develop Jan 20, 2019
@fisx fisx deleted the fisx-app-level-websocket-pongs branch January 20, 2019 17:04
@jschaul jschaul mentioned this pull request Feb 6, 2023
jschaul added a commit that referenced this pull request Feb 27, 2023
Introduces an integration test / regression test to check that control-level pings with a payload result in a control-level pong with the same payload as specified in the [RFC](https://www.rfc-editor.org/rfc/rfc6455#section-5.5.2)

This was used in debugging https://wearezeta.atlassian.net/browse/FS-1489

(related ping-pong prior work: #561 and prior discussion: #560)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants