我使用Play框架2.1调用web服务,这需要超过10秒。因为我总是收到以下错误:
play.api.Application$$anon$1: Execution exception[[TimeoutException: Futures timed out after [10000 milliseconds]]]
at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.0]
at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10.jar:2.1.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:132) [play_2.10.jar:2.1.0]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:128) [play_2.10.jar:2.1.0]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.0]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.0]
java.util.concurrent.TimeoutException: Futures timed out after [10000 milliseconds]
at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:96) ~[scala-library.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:58) ~[scala-library.jar:na]
at scala.concurrent.Await$$anonfun$ready$1.apply(package.scala:86) ~[scala-library.jar:na]
at scala.concurrent.Await$$anonfun$ready$1.apply(package.scala:86) ~[scala-library.jar:na]
如何增加超时值?
我试图更改以下值:
promise.akka.actor.typed.timeout play.akka.actor.typed.timeout
但没有成功......
提前感谢您的帮助
答案 0 :(得分:2)
不幸的是,它在框架中是硬编码的......请参阅https://github.com/playframework/Play20/blob/master/framework/src/play/src/main/scala/play/api/libs/concurrent/Promise.scala#L266
似乎已经开启了一个问题:https://github.com/playframework/Play20/issues/1002
答案 1 :(得分:2)
看起来它已经在2.3中得到修复,但它们不会支持任何2.2版本的端口
javaOptions in Test += "-Dtest.timeout=10000"
由于我使用2.2这对我不起作用,但我希望它适用于2.3
的人答案 2 :(得分:0)
如果您正在编写单元测试,那么就是这样做的。
@Test
public void testInServer() {
running(testServer(3333), new Runnable() {
public void run() {
assertThat(
WS.url("http://localhost:3333").get().get(timeout).getStatus()
).isEqualTo(OK);
}
});
}