spray, scala : change the timeout

强颜欢笑 提交于 2019-12-24 08:59:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!