Connection disconnects after few seconds using Dar...
# ktor
c
Connection disconnects after few seconds using Darwin engine for websocket on iOS. But it worked well when I switched to CIO. Any one ever experience this?
a
Could you please share your code?
c
Creating the client
Copy code
private val client = HttpClient {
    install(WebSockets) {
        pingInterval = 20_000
        contentConverter = KotlinxWebsocketSerializationConverter(Json {
            ignoreUnknownKeys = true
            isLenient = true
        })
    }
}
Connecting to server
Copy code
client.wss("<ws://localhost:8080/connect/$username>") {
        socket = this
        try {
                while (true) {
                    val frame = incoming.receive()
                    if (frame is Frame.Text){
                        println(frame.readText())
                    }
                }
            }
        } catch (e: ClosedReceiveChannelException) {
            println("Closed=${e.message}")
        }
    }
a
Could you please try to replace
client.wss
with
<http://client.ws|client.ws>
, because seems like the connection is insecure?
c
My bad, I was testing on a live server before I switched to test on local. But its still the same error though
So I did what you asked. Same error.
Close reason: CloseReason(reason=INTERNAL_ERROR, message=Ping timeout)
@Aleksei Tirman [JB] were you able to reproduce??
I thought i could just use CIO but it doesnt support TLS on native
a
Unfortunately, I cannot reproduce this problem with your code on the macosX64 target. Could you please share a code sample where a connection is established to wss://ws.postman-echo.com/raw?