Hi all,
I had the below questions regarding the Websocket config for the JSON API service.
May I know if
- There is a default timeout set for the JSON API websocket?
- Is it possible to set no timeout for the JSON API websocket?
JSON API Websocket example config section available on the docs:
//Optional websocket configuration parameters
websocket-config {
//Maximum websocket session duration
max-duration = 120m
//Server-side heartbeat interval duration
heartbeat-period = 5s
//akka stream throttle-mode one of either shaping
or enforcing
mode = “shaping”
}
Thank you!
2 Likes
The default timeout is 2 hours. You cannot set WebSocket session to never expire. You can however set it to an arbitrarily large value (see here on how to specify a duration in HOCON), but this would mean that a growing number of possibly inactive clients would open streams to the server that might use resources and mostly go unused from a functional perspective. The recommendation is to keep it low (two hours is already very generous, possibly excessive) and handle gracefully connections being closed (which might happen anyway regardless of the configuration limit – e.g. due to a transient network error), possibly limiting the open streams to the bare essential to avoid overwhelming the server.
See this ticket for further details.
1 Like
To put it a little more strongly: as discussed earlier in that ticket, setting a very long timeout cannot possibly give you the desired client behavior of a “stream that keeps working indefnitely”. So if your application doesn’t work right with the duration set to 5 minutes, it will not be well-behaved anyhow.
1 Like
Well noted @Stephen thank you!