playframework / playframework/play-ws

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

Open
#202 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:backlog
Dominant language
Scala
Stars
224
Forks
92
Avg merge
1d 19h
Merged PRs (30d)
28

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the wsRequest API and trace how requests reach the underlying async HTTP client. Check how Scala and Java request APIs configure streaming requests, then verify that a configurable read timeout, including Duration.Inf, prevents the reported timeout in long-running streams.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.