spray,scala:更改超时

spray,scala:更改超时,scala,timeout,spray,Scala,Timeout,Spray,我想更改喷洒应用程序中的超时,但最简单的方法是什么?我在github上看到了一些示例,但它们相当复杂 谢谢 我试过这个: class MyServiceActor extends Actor with MyService { sender ! SetRequestTimeout(scala.concurrent.duration.Duration(120,"second")) sender ! spray.io.ConnectionTimeouts.SetIdleTimeout(scala.c

我想更改喷洒应用程序中的超时,但最简单的方法是什么?我在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 )
}

但是超时似乎停留在约5秒。

您应该能够使用底层spray can服务器的超时配置值来配置超时

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

有几次暂停。更改它们的最简单方法是更改配置设置。有关设置列表和说明,请参见此处:您好,谢谢,但我应该将这段代码放在哪里?在您的应用程序配置中。请参见示例投影仪,因为它是独立的,请查看模板项目: