samedi 23 juillet 2016

Using stetho with okHttp raises java.net.SocketException

I am using facebook's open source project stetho to debug my android app. I use okHttp as the http client. The code snippet:

OkHttpClient.Builder builder = new OkHttpClient.Builder();
//builder.addNetworkInterceptor(new StethoInterceptor());
OkHttpClient client = builder.build();
Request request = new Request.Builder().url(url).build();
try {
    Response response = client.newCall(request).execute();
} catch (IOException e) {
    e.printStackTrace();
}

When I comment the second line, I can successfully get the response. However, if I add the second line, exception is raised:

java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)

Aucun commentaire:

Enregistrer un commentaire