本文介绍了喷雾,Scala:更改超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想更改喷涂应用程序中的超时时间,但实现此目的的最简单方法是什么?我在github上看到了一些例子,但它们相当复杂.
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.
谢谢.
我试过了:
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 秒.
but the timeout seems to stay at ~5 seconds.
推荐答案
您应该能够使用底层喷罐服务器的超时配置值来配置超时
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
}
这篇关于喷雾,Scala:更改超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!