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

1

7

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?

Grebe answered 2/7, 2017 at 16:50 Comment(0)
G
13

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

Grebe answered 3/7, 2017 at 16:47 Comment(1)
Does this mean keys such as akka.http.server.idle-timeout have no effect in the play framework?Delay

© 2022 - 2024 — McMap. All rights reserved.