6

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.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
ND1010_
  • 3,743
  • 24
  • 41
  • Most POST requests require a slash `/` at the end of the URL. – Viktor Stojanov Jun 29 '18 at 07:05
  • @ViktorStojanov please read my Question properly , the issue when i getting is while i use pro proguard and other thing is with proguard single request are working perfectly fine – ND1010_ Jun 29 '18 at 07:10
  • @ND1010_ did you find any solution? I think this is a bug in OkHttp but they dont want accept and resolve it! I did server monitoring by tcpdump and it seems sometimes my request are not coming to server at all! – Ghasem Sadeghi Feb 07 '20 at 13:26

0 Answers0