why is play framework timing out?

2019-02-05 16:19发布

问题:

I am starting the the application from the command line using either

    activator run 
    activator ~run

or after I start the activator console I use run or ~run.
everything seems to work and it gives the expected

 --- (Running the application, auto-reloading is enabled) ---

   play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

   (Server started, use Ctrl+D to stop and go back to the console...)

I can view the application in the browser and I can make changes in the code and they are reloaded just fine. the issue is that after only a couple minutes it seems like something "times-out" because if I try to reload after this the browser just sits there spinning. if i let it spin long enough I get.

[error] application - 
[info] 
[info] ! Internal server error, for (GET) [/] ->
[info] 
[info] java.util.concurrent.TimeoutException: Futures timed out after [300000 milliseconds]
[info]  at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219) ~[scala-library-2.11.1.jar:na]
[info]  at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223) ~[scala-library-2.11.1.jar:na]
[info]  at scala.concurrent.Await$$anonfun$result$1.apply(package.scala:111) ~[scala-library-2.11.1.jar:na]
[info]  at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53) ~[scala-library-2.11.1.jar:na]
[info]  at scala.concurrent.Await$.result(package.scala:111) ~[scala-library-2.11.1.jar:na]

I would really appreciate any help. Since having to restart the app all over again each time I make a change really takes away the appeal of the framework.

回答1:

I upgraded to activator 1.3.2 with Play 2.3.9 and I also had the same issue. It drove me nuts. I found that the cause was the new set "fork in run" setting added in activator 1.3.2.

Open up build.sbt and you will find :

fork in run := true

Set this to false as follows :

fork in run := false


回答2:

Running activator start or better sbt start fixes the issue as well without having to remove the forking behavior.