perwendel / spark

A simple expressive web framework for java. Spark has a kotlin DSL https://github.com/perwendel/spark-kotlin
Apache License 2.0
9.63k stars 1.56k forks source link

Spark.webSocketIdleTimeoutMillis should handle Long instead of Integer #1146

Open Tanaht opened 4 years ago

Tanaht commented 4 years ago

Hello all,

I need to inform you about a little details that I care about.

The connection between WebSocket Server and a WS client shutdown itself if there is no websocket events for a duration greater thant the idleTimeoutMillis value

Normally Websocket shoudln't have such timeout policy, my guess is it's an implementation issues with Jetty (but it's not the discussion here)

The underlying Jetty Websocket implementation use long primitive for this value see WebSocketPolicy#setIdleTimeout(long ms). But SparkJava API provide integer in the method Spark#webSocketIdleTimeoutMillis(int timeoutMillis)

For information the mapping between SparkJava API and Websocket API is done in this class: WebSocketServletContextHandlerFactory

So we have less control over this value, and on some use case it can be useful to declare Idle Timeout to a big number:

Small impacts (IMO), but this feature is probably not the most wanted :)

That's all.