Spray, scala:改变超时时间



我想在喷雾应用程序中更改超时,但是实现这一目标的最简单方法是什么?我在github上看到了一些例子,但是它们相当复杂。

谢谢。

我试过了:

class MyServiceActor extends Actor with MyService {
sender ! SetRequestTimeout(scala.concurrent.duration.Duration(120,"second"))
sender ! spray.io.ConnectionTimeouts.SetIdleTimeout(scala.concurrent.duration.Duration(120,"second"))
// the HttpService trait defines only one abstract member, which
// connects the services environment to the enclosing actor or test
def actorRefFactory = context
// this actor only runs our route, but you could add
// other things here, like request stream processing
// or timeout handling
def receive = runRoute( myRoute )
}

您应该能够使用底层喷雾罐服务器的超时配置值来配置超时

spray.can.server {
  request-timeout = 2s
}

最新更新