Ktor: Ktor-Client-iOS truncates JSON responses

Created on 12 Dec 2018  路  5Comments  路  Source: ktorio/ktor

Ktor Version

1.0.1

Ktor Engine Used(client or server and name)

ktor-client, ktor-client-android and ktor-client-ios

JVM Version, Operating System and Relevant Context

iOS

Feedback

We are developing a multiplatform app for Android and iOS. While for Android everything works smoothly, we are facing an issue with iOS version and Ktor client. It seems that randomly, calling the API, the response is truncated and we receive partial JSON data. We also tried starting from scratch using the Ktor Sample MPP App and we have the same behaviour simply changing the endpoint.

Here the Ktor sample app code changed:

package io.ktor.samples.mpp.client

import io.ktor.client.*
import io.ktor.client.request.*
import io.ktor.http.*
import kotlinx.coroutines.*

internal expect val ApplicationDispatcher: CoroutineDispatcher

class ApplicationApi {
    private val client = HttpClient()

    //var address = Url("https://tools.ietf.org/rfc/rfc1866.txt")
    var address = Url("https://newsapi.org/v2/top-headlines?apiKey=cfe7a44a40e041ccaf8b9de9b1c71c28&country=us")

    fun about(callback: (String) -> Unit) {
        GlobalScope.apply {
            launch(ApplicationDispatcher) {
                val result: String = client.get {
                    url([email protected]())
                }

                callback(result)
            }
        }
    }
}
bug

Most helpful comment

Hi, @spawn150. Thanks for the report.

It's obviously a bug and would be fixed in the next minor release.

All 5 comments

Hi, @spawn150. Thanks for the report.

It's obviously a bug and would be fixed in the next minor release.

Hi @e5l , I have the exact same issue. I'm developing a multiplatform app that calls some rest apis and the response randomly gets truncated. Do you know when the fix could be available?
Thanks

Could you reproduce the issue with 1.1.2?

Fixed in 1.1.3.

Was this page helpful?
0 / 5 - 0 ratings