eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.24k stars 2.06k forks source link

Customize a server WebSocket's idle timeout #1985

Open mrb-twx opened 7 years ago

mrb-twx commented 7 years ago

It would be useful if Vert.x permitted the idle timeout to be set on a per WebSocket basis.

Currently, the idle timeout for a server WebSocket can only be set via io.vertx.core.http.HttpServerOptions#setIdleTimeout, but because this is an HTTP server option it applies to all server WebSockets. This prevents someone from specifying different WebSocket idle timeouts based on things like the URI, path, or headers.

vietj commented 7 years ago

would you mind to contribute such feature ?

mrb-twx commented 7 years ago

Sure, I'll take a look at it.

sliechti commented 1 year ago

@vietj if you share some pointers I may be able to contribute the patch. Not being able to set idle timeout at the websocket level is problematic. If we set the HTTP timeout too high, let's sat 30s/60s we can potentially have lingering HTTP connections and that may turn into a scalability issue. If we set the timeout too low, we are forced to send pings or heartbeats over websocket which would translate in unnecessary traffic.

vietj commented 1 year ago

how does the code decide when the timeout should be changed ?

sliechti commented 1 year ago

@vietj I don't know if Netty has a way to differentiate a regular HTTP connection from a Websocket one but one way I can think of this could be done is based on HTTP headers, if the request has the upgrade request the "setWebSocketIdleTimeout" applies.

vietj commented 1 year ago

I see now indeed it could be done after the upgrade

sliechti commented 1 year ago

@vietj thank you for adding to the roadmap!