Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does play 2.6 close a websocket after 85 seconds when it is idle? While play 2.5 does not

After updating to play 2.6 I noticed that the websocket connection gets closed after 85 seconds when it is idle. In play 2.5 however the websocket connection stays open for +15 minutes when idle.

What changed in play 2.6 and is there a way to keep the websocket connection open in play 2.6 without manually keeping the connection alive on the application level?

like image 954
DP Greveling Avatar asked Jul 02 '17 16:07

DP Greveling


People also ask

Does WebSocket connection timeout?

A WebSocket times out if no read or write activity occurs and no Ping messages are received within the configured timeout period. The container enforces a 30-second timeout period as the default. If the timeout period is set to -1 , no timeout period is set for the connection.

What is WebSocket timeout?

The websocket-idle-timeout command sets the maximum idle time for client connections with the handler. This timer monitors the idle time in the data transfer process. If the specified idle time is exceeded, the connection is torn down.


1 Answers

It seems that for Play 2.6 akka http instead of netty is used for the backend. This means that a default timeout configuration is set for the akka http server.

The idle timeout can be increased by adding the following to the applications.conf file.

play.server.http.idleTimeout = 180s

However according to the play documentation:

Note: In dev mode, when you use the run command, your application.conf settings will not be picked up by the server. This is because in dev mode the server starts before the application classpath is available.

Thus for testing with longer idleTimeout one could run the play instance using:

sbt run -Dplay.server.http.idleTimeout=180s

For further documentation see:

https://www.playframework.com/documentation/2.6.x/SettingsAkkaHttp
http://doc.akka.io/docs/akka-http/current/java/http/server-side/websocket-support.html

like image 166
DP Greveling Avatar answered Sep 19 '22 22:09

DP Greveling