Why do I get a very long timeout in my PlayFramework app?

跟風遠走 提交于 2019-12-21 20:57:32

问题


I have created a working app, but sometimes when I change things and hit the "Reload"-Button in my browser, the app takes forever to time out (300000ms or 5 minutes!). After that I get the following exception in the browser:

java.util.concurrent.TimeoutException: Futures timed out after [300000 milliseconds]
scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219)
scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223)
scala.concurrent.Await$$anonfun$result$1.apply(package.scala:111)
scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53)
scala.concurrent.Await$.result(package.scala:111)
play.forkrun.ForkRun$$anonfun$askForReload$1.apply(ForkRun.scala:123)
play.forkrun.ForkRun$$anonfun$askForReload$1.apply(ForkRun.scala:121)
play.runsupport.Reloader.reload(Reloader.scala:295)
play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:122)
play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scalscala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1361)
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

The error in the console:

[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]

Most of the time I simply stop the activator (CTRL+D in the console) and then restart it with 'activator run', the app works then.

I have tried it with the activator 1.3.2 and even with the offline distribution on different computers, but to no avail.

I'm using the Scala IDE 4.0 (Eclipse).

[EDIT]: I have also tried activator ~run, so changes will be compiled asap.

An example for a change that timed out:

(I simply have added the first line $document.ready(function()and the corresponding brackets at the end). After I got the timeout, I stopped the activator run by CTRL+D and re-started it by activator run. I did not change any of my code! When the start was complete, my program functioned as intended.

 <script>
        $(document).ready(function() {
            $('#icon').click(function() {
                var $this = $(this);
                $this.css("color","orange");
                var num = $('#num');
                var currentNumber = num.text().length ? parseInt(num.text()) : 0;
                num.text(currentNumber + 1);
            });
        });
    </script>

I get these timeouts very often now, like in 90% of my code changes which is very annoying.

So how can I fix the very long timeout?


回答1:


I seem to have found the answer myself while googling for the edit in my first post. I write this down so it might help somebody with a similar problem:

In activator 1.3.2 a "fork in run"-settting has been added. So the activator UI adds the line fork in run := true to your build.sbt in the project.

Simply remove, comment out or change the line to fork in run := false. This fixed my timeouts.

Worth mentioning: the compiling of my project is now much faster than before.

I still dont understand fully why the timeouts happen, if someone has more insight into this I would gladly hear it. But for now I have a functioning workaround.



来源:https://stackoverflow.com/questions/29747778/why-do-i-get-a-very-long-timeout-in-my-playframework-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!