square / okhttp

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.
https://square.github.io/okhttp/
Apache License 2.0
45.86k stars 9.16k forks source link

SocketTimeoutException on Android #623

Closed takke closed 10 years ago

takke commented 10 years ago

Using version: 1.5.0 release Platform: Android 4.4.2 (Nexus5)

I'm developing twitter client app for android using Twitter4J.

I made a module for Twitter4J to support SPDY & HTTP/2.0 using OkHttp-1.5.

So I tried to implement the module to my app, but I found problem below.

Stack trace:

Caused by: java.net.SocketTimeoutException: Read timed out
    at com.squareup.okhttp.internal.spdy.SpdyStream$SpdyDataSource.waitUntilReadable(SpdyStream.java:412)
    at com.squareup.okhttp.internal.spdy.SpdyStream$SpdyDataSource.read(SpdyStream.java:364)
    at com.squareup.okhttp.internal.http.SpdyTransport$SpdySource.read(SpdyTransport.java:264)
    at com.squareup.okhttp.internal.okio.RealBufferedSource$1.read(RealBufferedSource.java:168)
    at java.io.InputStream.read(InputStream.java:162)

The app gets the user's timeline using Twitter.getHomeTimeline() method. To set the fetch count as 160 is OK. But when set the count = 170, it spends very very long time, and timed out.

Sample project: https://github.com/takke/OkHttpTimedOutSample

codefromthecrypt commented 10 years ago

Hi @takke Does this timeout happen when inside a unit test as well, or only on the device?

swankjesse commented 10 years ago

https://github.com/square/okhttp/pull/625