android - 如何解决 okhttp3.internal.http2.StreamResetException : stream was reset: REFUSED_STREAM in Retrofit POST request

标签 android retrofit2 okhttp3

我正在使用改造将数据传递到服务器。但得到以下异常响应:

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/

相关文章:

connection-pooling - OkHttp如何设置最大连接池大小(不是最大空闲连接数)

OkHttp3 日志拦截器不记录 cookie

android - 在 Android 终端中运行 Python for Android (Qpython)

android - 一个 NFC 标签上的两个 Action

java - 使用 Retrofit 选择某个 ID

android - 使用 Retrofit 响应的 NullPointerException

android - 无法解决错误 BEGIN_ARRAY 但为 BEGIN_OBJECT

android - Android Fragment中的Retrofit2如何正确实现?

android - 转换OkHttp以使用Gradle构建系统

android - Socket 连接建立时发出蜂鸣声通知