我正在使用改造将数据传递到服务器。但得到以下异常响应:
okhttp3.internal.http2.StreamResetException:流被重置:REFUSED_STREAM
对于上述异常,我引用了以下链接:
java.io.IOException: stream was reset: REFUSED_STREAM on several devices
并将改造和 okhttp 版本更新为以下内容:
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.5.0'
仍然没有解决问题。如何解决?
最佳答案
响应为时已晚,您可能已经解决了问题,但在我的情况下,我解决了在 OKHttpClient
中添加协议(protocol)的问题:
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.protocols( Collections.singletonList(Protocol.HTTP_1_1) );
问候!
关于android - 如何解决 okhttp3.internal.http2.StreamResetException : stream was reset: REFUSED_STREAM in Retrofit POST request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53648852/