play-ws icon indicating copy to clipboard operation
play-ws copied to clipboard

[feature] Allow setting read timeout of underlying async HTTP client Request

Open rpiaggio opened this issue 8 years ago • 3 comments

Be able to set wsRequest.withReadTimeout(duration), mainly to avoid read timeout exceptions in long-running stream requests.

Play WS Version (2.5.x / etc)

2.6+

API (Scala / Java / Neither / Both)

Both

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

Use uname -a if on Linux.

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

Paste the output from java -version at the command line.

Library Dependencies

If this is an issue that involves integration with another system, include the exact version and OS of the other system, including any intermediate drivers or APIs i.e. if you connect to a PostgreSQL database, include both the version / OS of PostgreSQL and the JDBC driver version used to connect to the database.

Expected Behavior

Example:

  • Set wsRequest.withReadTimeout(Duration.Inf).
  • Initiate a long-running streaming request with .stream.
  • Stop getting these exceptions:
Caused by: java.util.concurrent.TimeoutException: Read timeout to localhost/127.0.0.1:5984 after 120000 ms
        at play.shaded.ahc.org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
        at play.shaded.ahc.org.asynchttpclient.netty.timeout.ReadTimeoutTimerTask.run(ReadTimeoutTimerTask.java:54)
        at play.shaded.ahc.io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:663)
        at play.shaded.ahc.io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:738)
        at play.shaded.ahc.io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:466)
        at java.lang.Thread.run(Thread.java:748)

Actual Behavior

There's currently no way to set read timeout, which defaults to 120000ms.

rpiaggio avatar Dec 08 '17 18:12 rpiaggio

Can this be overriden in config? My stream was failing with a "502 Bad Gateway" after 85 seconds, but the setting play.server.http.idleTimeout = 900 seconds in application.conf fixed that, only for it to subsequently fail with "Read timeout after 120000 ms" at 2 minutes.

RichardSmithONS avatar Jan 18 '18 12:01 RichardSmithONS

Any known workarounds or updates here?

qbrent avatar Jan 31 '18 12:01 qbrent

play.ws.timeout.request=900s play.ws.timeout.idle=900s play.ws.timeout.connection=900s

in the application.conf allowed my long requests to work - previously I was getting a numberformat exception when setting these values, not knowing that in Play 2.6 you have to include the time units (e.g. s or ms)

RichardSmithONS avatar Feb 01 '18 10:02 RichardSmithONS