Execution exceptionAskTimeoutException: Timed out playframework

纵饮孤独 提交于 2019-12-11 20:32:32

问题


I'm calling a method from Ajax... and PlayFramework 2.1.3

$.ajax({
  type: "POST",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  url: "/examplefoo",
  data: JSON.stringify(exampleArray),
  success: function(data) {
    doSomething();
  },
  error: function(e) {
    console.log(e);
  }
});

On Application.java

I call a method that does a huge computation and this spend a lot of time...

@BodyParser.Of(play.mvc.BodyParser.Json.class)
public static Result examplefoo() throws SQLException, IOException {
    DAOFoo fooDAO = new DAOFoo();
    result = fooDAO.methodOfHugeComputation();

    return ok(play.libs.Json.toJson(result));
}

After 50 minutes of processing more or less I got this timeout error:

[error] application -

! @6fnm1gafo - Internal server error, for (POST) [/examplefoo] ->

play.api.Application$$anon$1: Execution exception[[AskTimeoutException: Timed out]]
    at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.3]
    at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10.jar:2.1.3]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$play$core$server$netty$PlayDefaultUpstreamHandler$$handle$1$1.apply(PlayDefaultUpstreamHandler.scala:143) [play_2.10.jar:2.1.3]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$play$core$server$netty$PlayDefaultUpstreamHandler$$handle$1$1.apply(PlayDefaultUpstreamHandler.scala:139) [play_2.10.jar:2.1.3]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.3]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.3]
akka.pattern.AskTimeoutException: Timed out
    at akka.pattern.PromiseActorRef$$anonfun$1.apply$mcV$sp(AskSupport.scala:310) ~[akka-actor_2.10.jar:na]
    at akka.actor.DefaultScheduler$$anon$8.run(Scheduler.scala:193) ~[akka-actor_2.10.jar:na]
    at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:137) ~[akka-actor_2.10.jar:na]
    at scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1417) ~[scala-library.jar:na]
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:262) ~[scala-library.jar:na]
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:975) ~[scala-library.jar:na]

Somebody knows a better manner to do that?

Thanks in advance.


回答1:


You can refer this link

This error comes because the play server doesnt get the enough thread to process the request. Since the method fooDAO.methodOfHugeComputation() takes a lot of time to process whiich doesnt releases the threads from your thread pool, thats why you need to increase your thread pool and processes by configuring your akka actors. You have a blocking I/O method so you need to use highly syncronous configuration.Check Out following documentation http://www.playframework.com/documentation/2.1.x/ThreadPools.

Also check whether you application is not consuming high memory which can also be a reason for not creating new threads for the process.

Also refer this links

  • https://groups.google.com/forum/#!topic/play-framework/EhK53q614T4
  • Play framework 2.0.x AskTimeoutException


来源:https://stackoverflow.com/questions/19167702/execution-exceptionasktimeoutexception-timed-out-playframework

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