在okHttp中使用stetho会引发java.net.SocketException

时间:2016-06-21 03:54:19

标签: android okhttp3 stetho

我正在使用facebook的开源项目 stetho 来调试我的Android应用。我使用okHttp作为http客户端。代码段:

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();
}

当我评论第二行时,我可以成功获得响应。但是,如果我添加第二行,则会引发异常:

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

0 个答案:

没有答案