playframework / play-ws

Standalone Play WS, an async HTTP client with fluent API
https://www.playframework.com/documentation/latest/JavaWS
Apache License 2.0
223 stars 87 forks source link

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

Open rpiaggio opened 6 years ago

rpiaggio commented 6 years ago

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:

Actual Behavior

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

RichardSmithONS commented 6 years ago

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.

qbrent commented 6 years ago

Any known workarounds or updates here?

RichardSmithONS commented 6 years ago

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)