https://kotlinlang.org logo
#ktor
Title
# ktor
b

brabo-hi

01/25/2022, 1:37 AM
Hi all, it looks like you can’t cash
HttpClient
with
CIO
when using
WebSockets
. But it looks working fine with Http ? Here is the error i am getting Kotlin multiplatform: JobCancellationException: Parent job is Completed
a

Aleksei Tirman [JB]

01/25/2022, 8:39 AM
Could you please share a code snippet to reproduce your problem?
b

brabo-hi

01/25/2022, 5:31 PM
Copy code
class MyService {
    private val client= HttpClient {
       install(WebSockets)
    }
    fun openSocket() {}
    fun closeSocket(code: Int, reason: String) {}
    fun sendMessage(msg:String) {}
}
The issue was when using the same instance of
MyService
Copy code
val myService = MyService()
myService.sendMessage();
Here i want to reuse the same
myService
instead of creating a new instance each time i want to start a new connection
2 Views