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

Add support for automatic pinging in WebSocket server implementation with configurable rate #102

Closed
akka-ci opened this issue Sep 8, 2016 · 13 comments
Assignees
Labels
help wanted Identifies issues that the core team will likely not have time to work on t:core Issues related to the akka-http-core module
Milestone

Comments

@akka-ci
Copy link

akka-ci commented Sep 8, 2016

Issue by fommil
Sunday Jul 12, 2015 at 11:01 GMT
Originally opened as akka/akka#17968


@jrudolph I just realised there doesn't appear to be a way to specify the ping rate from the server to the client. This is not something that the application level code should be concerned with.

It's actually a really big pain in the wandoulabs implementation because even if the user's code uses proper backpressure, then protocol layer Ping/Pongs can still blow up the network stack and that means a lot more error handling is required a lot higher up the stack than desirable. I worked around this in smootoo/simple-spray-websockets@17ea453 (note that we forked wandoulabs, because it seems to be a zombie project)

@akka-ci akka-ci added this to the http-backlog milestone Sep 8, 2016
@akka-ci akka-ci added the t:http label Sep 8, 2016
@akka-ci
Copy link
Author

akka-ci commented Sep 8, 2016

Comment by jrudolph
Monday Jul 13, 2015 at 09:13 GMT


Automatic server-side ping is not mandatory in the spec and it's not implemented so far.

In any case, just setting the rate would always help for one specific networking setup. The only robust solution is providing backpressure throughout the whole processing chain. For Websocket this means that there needs to be some frame sending management that organizes how data from these three sources should be sequenced and backpressured:

  • outgoing user data
  • auto-generated PINGs (maybe only on idle connections?)
  • PONG answers in response to peer PINGs

User-data will be back-pressured through the existing streaming API, PONG answers will effectively start to backpressure the incoming side, and auto-generated PING could theoretically be dropped if there's backpressure from the network.

@akka-ci
Copy link
Author

akka-ci commented Sep 8, 2016

Comment by jrudolph
Monday Jul 13, 2015 at 09:22 GMT


So, for user-code the rule is that it needs to support the backpressure from the streams API.

Relying on the rest of the stack (server-side websocket, server-side networking configuration and implementation, network, peer-side networking configuration and implementation, peer-side websocket implementation, peer-side application) to provide any guarantees on being backpressure-free will always be brittle. Even if things seems to work in the good cases (localhost, big enough buffers, good enough network, etc.) it will fail rarely and unexpectedly under load.

@akka-ci
Copy link
Author

akka-ci commented Sep 8, 2016

Comment by ktoso
Tuesday Oct 20, 2015 at 12:07 GMT


Doesn't sound like we have a clear idea how to solve this yet, such that PINGs don't starve the actual user-code etc... right?

Marking as 1.x for now // cc @rkuhn @sirthias @jrudolph

@akka-ci
Copy link
Author

akka-ci commented Sep 8, 2016

Comment by drewhk
Tuesday Oct 20, 2015 at 12:14 GMT


It is simple to do with a GraphStage. I planned to have an "idle-inject" stage which is the counterpart of the "idle-timeout" stage.

@akka-ci
Copy link
Author

akka-ci commented Sep 8, 2016

Comment by ktoso
Thursday Apr 07, 2016 at 13:32 GMT


We nowadays have keepAlive, we can investigate how to apply it here perhaps.

@akka-ci
Copy link
Author

akka-ci commented Sep 8, 2016

Comment by ktoso
Thursday Apr 07, 2016 at 13:40 GMT


Auto ping also requested by people from Play community BTW akka/akka#18126 (comment)

@akka-ci
Copy link
Author

akka-ci commented Sep 8, 2016

Comment by ianclegg
Thursday Jul 14, 2016 at 10:28 GMT


Some kind of support for ping/pong frames in Akka Http would be nice - at the moment we have to handle this much higher up at the application level with ping binary messages and our own sequence numbers. It certainly requires some careful thought, but it would be useful to have. 👍

@ktoso ktoso added 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted and removed t:http labels Sep 8, 2016
@gilbertw1
Copy link

👍 I'd also like to see this supported on the client side. I'm currently migrating my slack client from spray-websocket and not having any form of access to Ping/Pong frames prevents me from adequately detecting dropped connections at the websocket level.

@jrudolph jrudolph added the help wanted Identifies issues that the core team will likely not have time to work on label Nov 7, 2016
@Tvaroh
Copy link

Tvaroh commented Nov 23, 2017

Why not implement PingMessage as a sub-class of Message and update MessageToFrameRenderer to be aware of it, at least to allow sending ping messages from the application code?

@ktoso
Copy link
Member

ktoso commented Nov 24, 2017

Feel free to give it a shot and send in a PR :) As you can see, it's a help wanted one, after all :)

@Tvaroh
Copy link

Tvaroh commented Nov 24, 2017

@ktoso the problem is Message is sealed and introducing another descendant will break compatibility.

@ktoso ktoso added the 2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding label Mar 13, 2018
@ktoso ktoso self-assigned this Mar 13, 2018
@ktoso ktoso modified the milestones: backlog, 10.1.1 Mar 13, 2018
@ktoso
Copy link
Member

ktoso commented Mar 13, 2018

I'll work on this, this week

@ktoso ktoso added 3 - in progress Someone is working on this ticket and removed 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted 2 - pick next Used to mark issues which are next up in the queue to be worked on. The tag is non-binding labels Mar 15, 2018
ktoso added a commit to ktoso/akka-http that referenced this issue Mar 16, 2018
ktoso added a commit to ktoso/akka-http that referenced this issue Mar 26, 2018
ktoso added a commit to ktoso/akka-http that referenced this issue Mar 26, 2018
ktoso added a commit to ktoso/akka-http that referenced this issue Mar 26, 2018
ktoso added a commit that referenced this issue Mar 27, 2018
* +htc #102 transparent keep-alive Ping/Pong for websocket

fix docs include

* fir compilation for 2.11, forgot main build is 2.12 nowadays and applied
change too eagerly

* review feedback

* move mima filters
@ktoso ktoso added t:core Issues related to the akka-http-core module and removed 3 - in progress Someone is working on this ticket labels Mar 27, 2018
@ktoso
Copy link
Member

ktoso commented Mar 27, 2018

Done, will ship in 10.1.1 shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Identifies issues that the core team will likely not have time to work on t:core Issues related to the akka-http-core module
Projects
None yet
Development

No branches or pull requests

6 participants