Retrofit Sockettimeoutexception In Sending Multiparty Or Json Data In Android
Facing problem in sending a Mutipart or JSON data through retrofit lib Retrofit Interface @Multipart @POST('/api/v1/protected/updateprofile') void uploadPhoto(@Part('name') String
Solution 1:
I have this error a few days ago and I discovered that your solution is correct but add more time
private OkHttpClient getClient() {
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(5, TimeUnit.MINUTES);
client.setReadTimeout(5, TimeUnit.MINUTES);
return client;
}
For OkHttp3
private OkHttpClient getClient() {
OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.MINUTES)
.readTimeout(5, TimeUnit.MINUTES)
.build();
return client;
}
Solution 2:
For me the problem was from the server side.
I had to disable tcp_timestamp
by changing sysctl
configuration on the API server. Also, if you have other services working over TCP on the same machine i.e. Redis etc., you should watch out for how this affects them.
Found this from an issue on Github.
Post a Comment for "Retrofit Sockettimeoutexception In Sending Multiparty Or Json Data In Android"