9

I am using retrofit to pass data to server. But getting following exception in response :

okhttp3.internal.http2.StreamResetException: stream was reset: REFUSED_STREAM

I referred following links for the above exception: java.io.IOException: stream was reset: REFUSED_STREAM on several devices

and updated retrofit and okhttp versions to following :

implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.5.0'

Still issue is not resolved. How to fix it?

1 Answers1

17

It's too late to response and it's possible you got it the fix but in my case, I resolve the problem adding protocols in the OKHttpClient:

OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); 
httpClient.protocols( Collections.singletonList(Protocol.HTTP_1_1) );

Regards!

Moises Portillo
  • 828
  • 8
  • 12
  • If you want to know what's going on – most likely the problem is head of line blocking on bad networks. See https://www.twilio.com/blog/2017/10/http2-issues.html and https://http3-explained.haxx.se/en/why-quic/why-tcphol – Michał Łazowik Jul 28 '22 at 14:33