Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why am I getting a PROTOCOL ERROR from OkHttp request?

I've been searching for awhile on this topic. I'm trying to send data to my backend server using OkHttp. However, I am getting this error:

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

val client = OkHttpClient()
val response = client.newCall(
    Request.Builder()
           .addHeader("Authorization:", "Bearer $firebaseToken")
           .url("https://someURL/"+ podcastId.toString())
           .build())
    .execute()

I'm not sure if this has to do with the URL or my Authorization header? Any help would be appreciated, thanks in advance.

like image 993
C'Aira Shields Avatar asked Feb 23 '26 08:02

C'Aira Shields


1 Answers

I solved a similar problem by restricting the request to use HTTP 1, see:

OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setProtocols(Arrays.asList(Protocol.HTTP_1_1));
like image 50
Julian Corrêa Avatar answered Feb 25 '26 21:02

Julian Corrêa