ktorio / ktor

Framework for quickly creating connected applications in Kotlin with minimal effort
https://ktor.io
Apache License 2.0
12.78k stars 1.04k forks source link

Boringssl error when using IOS Engine #935

Open lehanphong opened 5 years ago

lehanphong commented 5 years ago

I using ktor_version = '1.1.2' and implementation "io.ktor:ktor-client-ios:$ktor_version" When I call post request from swift code to kotlin-native, so I don't see reponse from server (Android call success). Please help me!!! Thank you. This is my code //Swift

override func viewWillAppear(_ animated: Bool) {
          CommonKt.loginTestAbc(callback :self)
    }

//Kotlin-ios

actual class HttpClientEngineHelper {

   actual fun getEngine(): HttpClientEngine {
        val config = IosClientEngineConfig()
        config.configureRequest {
//            setTimeoutInterval(5.0)
        }
        return IosClientEngine(config)
    }
}

//Kotlin common

private val client : HttpClient by lazy {
        HttpClient(HttpClientEngineHelper().getEngine()) {

        }
    }
//MARK: call api
fun login(callback : OnListenerResponseApi)  {
        LogVnd.r("login")
        try {
            GlobalScope.launch { // launch new coroutine in the scope of runBlocking
                LogVnd.r("login launch")
                reqLogin(ReqLoginModel("username", "password"), callback)
            }
        } catch (e : Exception){
            LogVnd.r(e.message)
            callback.onError(e.message)
        }
}

suspend fun reqLogin(reqLoginModel: ReqLoginModel, callback: OnListenerResponseApi) {
        try {
            LogVnd.r("reqLogin")
            val res = client.call(loginUrl) {
                method = HttpMethod.Post
                addHeader(headers)
                body =  TextContent(Json.stringify(ReqLoginModel.serializer(), reqLoginModel), ContentType.Application.Json)
                LogVnd.d(ApiHelper.TAG, "$body")
            }.response
            LogVnd.d(
                TAG,
                "RES $res"
            )
            processResponseData(res, ResLoginModel::class, callback)
        } catch (e: Exception) {
            LogVnd.e(e)
            callback.onException()
        }
}

//Error from xcode after long time 019-02-08 17:35:51.111323+0700 DPro[35228:2047919] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7f89e9513e00] get output frames failed, state 8196 2019-02-08 17:35:51.111739+0700 DPro[35228:2047919] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x7f89e9513e00] get output frames failed, state 8196 2019-02-08 17:35:51.113152+0700 DPro[35228:2047919] TIC Read Status [1:0x0]: 1:57 2019-02-08 17:35:51.113267+0700 DPro[35228:2047919] TIC Read Status [1:0x0]: 1:57

lehanphong commented 5 years ago

@e5l this's your bug or my config? I waiting your reply!

e5l commented 5 years ago

Hi @lehanphong, sorry for dellay.

It looks like the problem from the thread: https://stackoverflow.com/questions/46352735/what-is-tic-read-status-157-in-ios11-xcode-9

I'm investigating now and try to fix it on Ktor level.

oleg-larshin commented 4 years ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

Stexxe commented 3 years ago

Do you still face this problem using Ktor 1.6.1?