How to delay spray server default timeout event?

55 views
Skip to first unread message

Allen Nie

unread,
Jul 25, 2015, 10:18:37 PM7/25/15
to spray.io User List
Hi,

    I'm using Spray framework to handle some serious mathematical computation that takes some time to calculate. However, before my actor can generate any response, Spray's default timeout would kick in and return "The server was not able to produce a timely response to your request." It seems like Spray cuts off connection longer than "1000ms". 

    I actually already have timeout built into my route:

    class FutureDemoService(futureDemoActor: ActorRef)(implicit system: ActorSystem)
  extends Directives {

implicit val timeout = Timeout(45 seconds)

lazy val route = pathPrefix("future") {
path("data") {
get {
getFromFile(new File("views/js/data1.json"), `application/json`)
}

    As you can see, no matter how I change this timeout value, it won't wait longer. How can I adjust Spray's default timeout event???

Sincerely,
Allen Nie

Joost den Boer

unread,
Sep 2, 2015, 5:34:39 AM9/2/15
to spray.io User List
I'm having the same issue with authentication. Since validating a password with BCrypt with large salt takes > 1 second the request is already rejected before authentication can complete.
How to increase the timeout for specific paths?

Joost den Boer

unread,
Sep 2, 2015, 5:46:55 AM9/2/15
to spray.io User List
Ok, was not thinking clearly yet.
My problem was caused by the [Scalatest]RouteTest expecting a response in 1 second. The overall request response is configured in the spray config and is much larger by default than 1 second. So at runtime, I do not expect any issues.

By adding `implicit val testTimeout = RouteTestTimeout(5 seconds)` in my test case, the test now succeeds.
Reply all
Reply to author
Forward
0 new messages