使用Pro-guard时遇到的问题 反对改造
HTTP FAILED: java.net.SocketException: recvfrom failed: ECONNRESET
(Connection reset by peer)
我知道已经问过这个问题,但是我面临的这个错误是来自其他情况... 找到与此错误相关的链接,但我没有任何适当的解决方案。
Getting "SocketException : Connection reset by peer" in Android
https://github.com/square/retrofit/issues/1027
我通过正文请求使用Retrofit
HTTP client
进行api调用。
@POST("users/new")
Call<User> createUser(@Body User user);
我的客户
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;
}
保护规则
# 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>;
}
问题:当我单次点击请求到服务器的响应将正常工作并获得服务器的响应,但是当我一次点击多个请求(对服务器的请求超过5个)时HTTP FAILED: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
注意:在没有proguard的情况下工作正常,但是当我添加proguard时,出现了上述问题
我还获得了此链接-> https://github.com/square/retrofit/issues/1027->但这很接近,没有任何解决方案。