Facing issue while using pro-guard against retrofit
HTTP FAILED: java.net.SocketException: recvfrom failed: ECONNRESET
(Connection reset by peer)
I know this question has been already asked, but this error which i am facing is from other scenario... Found links related to this error but i get doesn't any proper solution.
Getting "SocketException : Connection reset by peer" in Android
https://github.com/square/retrofit/issues/1027
I use Retrofit
HTTP client
for api calling by using body request.
@POST("users/new")
Call<User> createUser(@Body User user);
My Client
public static OkHttpClient getClient() {
if (client == null) {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
RequestInterceptor m1RequestInterceptor = new RequestInterceptor();
client = new OkHttpClient.Builder()
.connectTimeout(2, TimeUnit.MINUTES)
.readTimeout(2, TimeUnit.MINUTES)
.addInterceptor(interceptor)
.addInterceptor(m1RequestInterceptor)
.build();
}
return client;
}
Pro-guard rules
# Retain generic type information for use by reflection by converters and adapters.
-keepattributes Signature
# Retain service method parameters when optimizing.
-keepclassmembers,allowshrinking,allowobfuscation interface * {
@retrofit2.http.* <methods>;
}
Issue : When i hit request to server for response for single time will work perfect and got response from server, but when i hit multiple request at a time (more than 5 request to server) getting HTTP FAILED: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
Note: Works perfectly fine without proguard , but while i add proguard i got this above issue
I also got this link --> https://github.com/square/retrofit/issues/1027 --> But it was close and didn't get any solution for that.