Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve okhttp3.internal.http2.StreamResetException: stream was reset: REFUSED_STREAM in Retrofit POST request

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?

like image 320
Hrishikesh Yengul Avatar asked Dec 06 '18 10:12

Hrishikesh Yengul


1 Answers

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!

like image 184
Moises Portillo Avatar answered Nov 19 '22 08:11

Moises Portillo