okhttp icon indicating copy to clipboard operation
okhttp copied to clipboard

java.net.SocketTimeoutException

Open viphsx123 opened this issue 9 years ago • 8 comments

java.net.SocketTimeoutException: failed to connect to myhost after 600000ms: isConnected failed: ETIMEDOUT (Connection timed out)

myhost is ok。This error occurs frequently。The version of okhttp is 3.2.0

viphsx123 avatar Dec 12 '16 01:12 viphsx123

Please provide an executable test case to demonstrate the problem. I assume it's a layer lower than OkHttp.

swankjesse avatar Dec 12 '16 01:12 swankjesse

Hi @swankjesse I faced similar issue in upload image. We upgraded okhttp from version 2.3.0 to 3.4.2 even test on 3.5.0 , it works fine on high speed internet like wifi but when we used 3G/2G connection and try to upload around 200KB image file it throws SocketTimeoutException. I increase connection timeout to 50s from 10s(default) still face same issue. When I down grade to pervious version 2.3.0 it works charm.

Finally we are thinking to down grade version to 2.3.0 in our app. Could you please look into this issue on high priority?

Imran-ss avatar Dec 16 '16 13:12 Imran-ss

Set the timeout to 0 to disable it. We didn't have any timeouts until 2.5.0.

swankjesse avatar Dec 16 '16 14:12 swankjesse

@swankjesse I tried with 0 connection timeout same result new OkHttpClient.Builder().connectTimeout(0, TimeUnit.MILLISECONDS).build();

Imran-ss avatar Dec 17 '16 06:12 Imran-ss

The version of okhttp is 3.5.0 but got socket time error(when i am using cellular connection) otherwise in case of wifi it is working fine. @swankjesse before i have used HttpPost it is working fine.

sachinchoudhary085 avatar Jan 04 '17 07:01 sachinchoudhary085

hi @sachinchoudhary , I solved it by increase time out new OkHttpClient.Builder() .connectTimeout(90, TimeUnit.SECONDS).readTimeout(90, TimeUnit.SECONDS) .writeTimeout(90, TimeUnit.SECONDS).build(); I have given 90 sec you can give according to your desire. Hope it will also solve your issue.

Imran-ss avatar Jan 04 '17 08:01 Imran-ss

Having same scenario . Version 2.6.0

java.net.SocketTimeoutException: failed to connect to...... (port 42839) after 10000ms

amiyo-biswas avatar Jul 18 '19 13:07 amiyo-biswas

fine,is that someone give me help, okhttp version 3.12.7 in my app.

liuzhonghu avatar Jul 19 '21 10:07 liuzhonghu