执行exceptionAskTimeoutException:播放框架超时 [英] Execution exceptionAskTimeoutException: Timed out playframework

查看:306
本文介绍了执行exceptionAskTimeoutException:播放框架超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Ajax调用方法... 和PlayFramework 2.1.3

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);
  }
});

在Application.java上

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));
}

经过大约50分钟的处理后,我收到了此超时错误:

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?

提前谢谢.

推荐答案

您可以引用此链接

出现此错误是因为播放服务器没有获得足够的线程来处理请求. 由于方法fooDAO.methodOfHugeComputation()需要大量时间来处理,而这并不会从线程池中释放线程,因此这就是为什么您需要通过配置akka actor来增加线程池和进程的原因. 您有一个阻止I/O方法,因此您需要使用高度同步的配置.请查看以下文档 http://www.playframework.com/documentation/2.1.x/ThreadPools .

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.

也请参阅此链接

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

这篇关于执行exceptionAskTimeoutException:播放框架超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆