https://kotlinlang.org logo
Title
s

Sergioedcigreja

07/26/2019, 10:52 AM
Hey guys, quick question: Im getting a networkOnMainThread error when I do client.close().. what's the best way to close the client?
👀 1
e

e5l

07/26/2019, 11:52 AM
What version of ktor do you use?
s

Sergioedcigreja

07/26/2019, 11:55 AM
1.2.2
doesn't make much sense because I just replaced okhttp with android and the error doesnt occur
e

Evan R.

07/26/2019, 2:36 PM
Could you throw the client.close() inside a withContext to make sure it gets closed off the main thread?
s

Sergioedcigreja

07/26/2019, 7:56 PM
it's a multiplatform library. I have all my code inside a try catch and i'm closing it in the finally block. This code runs in a coroutine so I don't know what is causing this issue
And why the Android client doesn't have any issue but okhttp fails
e

Evan R.

07/26/2019, 8:31 PM
Where are you starting the coroutine? Where is the try catch?
s

Sergioedcigreja

07/27/2019, 8:17 PM
The try catch finally is inside a suspend function