问题
I want to change the timeout in a spray application, but what is the simplest way to achieve this? I saw some examples on github but they are rather complicated.
thanks.
I tried this :
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 )
}
but the timeout seems to stay at ~5 seconds.
回答1:
you should be able to configure the timeout using the timeout configuration value for the underlying spray can server
spray.can.server {
request-timeout = 2s
}
来源:https://stackoverflow.com/questions/22465235/spray-scala-change-the-timeout