Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spray.can.server.request-timeout property has no effect

Tags:

scala

spray

In my src/main/resources/application.conf I include:

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

In order to test this, in the Future which is servicing my request I put a Thread.sleep(10000).

When I issue a request, the server waits 10 seconds and responds with no hint of a timeout being sent to the client.

I am not overriding the timeout handler.

Why are my clients (chrome and curl) not receiving a timeout?

like image 886
Synesso Avatar asked Aug 20 '26 03:08

Synesso


1 Answers

The configuration looks correct, so Spray request timeout should be working. One of the frequent reasons for it not working is that your config application.conf is not being used by the application.

The reasons for config being ignored could be that it's in the wrong place, not included in your classpath, or not included in a JAR that you package.

To troubleshoot first check that default Spray timeout is working. By default it's 20 sec. Make your code sleep for 30sec and see if you get timeouts triggered.

Check what's in your final config values by printing it. Set this in your conf:

akka {
  # Log the complete configuration at INFO level when the actor system is started.
  # This is useful when you are uncertain of what configuration is used.
  log-config-on-start = on
}

Finally, keep in mind other timeouts like timeout-timeout = 2 s.

like image 52
yǝsʞǝla Avatar answered Aug 22 '26 12:08

yǝsʞǝla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!