vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

Customize a server WebSocket's idle timeout

Open mrb-twx opened this issue 7 years ago • 7 comments

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.

mrb-twx avatar May 11 '17 21:05 mrb-twx

would you mind to contribute such feature ?

vietj avatar May 18 '17 07:05 vietj

Sure, I'll take a look at it.

mrb-twx avatar May 22 '17 13:05 mrb-twx

@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.

sliechti avatar Jan 04 '23 17:01 sliechti

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

vietj avatar Jan 05 '23 09:01 vietj

@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.

sliechti avatar Jan 05 '23 17:01 sliechti

I see now indeed it could be done after the upgrade

vietj avatar Jan 06 '23 08:01 vietj

@vietj thank you for adding to the roadmap!

sliechti avatar Jan 08 '23 22:01 sliechti