Friday, 28 June 2019

OkHttp and Retrofit throws IO: Stream 3 not progressing

I'm getting a "IO: Stream 3 not progressing" in my Charles Proxy.

I have a simple RxJava call:

    subscription.add(api.sendSources(sendDataBody)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({
                callback.onFinished(it)
            }, {
                callback.onError(-1)
            }))

A simple POJO:

data class SendDataBody(
        @Json(name = "authtoken")
        var authToken: String,

) : Serializable

open class SendDataResponse(
        @Json(name = "success")
        var success: Boolean,

        @Json(name = "error")
        var error: String?
)

Here is my interface:

@Headers(
        "Content-Type: application/json; charset=UTF-8",
        "accept-encoding: gzip, deflate",
        "Accept: */*",
        "Cache-Control: no-cache"
)
@POST("sourcedata")
fun sendSources(@Body sendDataBody: SendDataBody) : Single<Any>

Here are the library versions:

// Retrofit
implementation "com.squareup.retrofit2:retrofit:2.3.0"
implementation "com.squareup.retrofit2:converter-moshi:2.3.0"
implementation "com.squareup.okhttp3:logging-interceptor:3.9.0"
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

// RxJava lib
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation "io.reactivex.rxjava2:rxjava:2.2.6"
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'

When inspecting with Charles, the first time the App always says "IO Stream 3 not progressing" but the App automatically does the call again and the second time it works fine. I haven't written any code to retry the API Call. When trying out the same using Postman, it works immediately. So it's not the back-end. I tried mimicking the headers of Postman and I also tried without RxJava, no difference.

enter image description here Second time works fine: enter image description here

When connecting with the debugger the error message is:

result = {Response@7889} "Response{protocol=h2, code=200, message=, url=https://api.myserver.nl/sourcedata}"
 body = "�\b�������������V*.MNN-.V�JK�)N�QJ-*�"
 errorBody = null

It seems that the response from the server is wrong but the second time the object is correct.



from OkHttp and Retrofit throws IO: Stream 3 not progressing

No comments:

Post a Comment