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

Sudhanshu Singh

09/22/2023, 8:50 PM
I am trying to connect to our websocket and get I am getting the following error
Copy code
io.ktor.network.tls.TLSException: Received alert during handshake. Level: FATAL, code: ProtocolVersion
                            	at io.ktor.network.tls.TLSClientHandshake$input$1.invokeSuspend(TLSClientHandshake.kt:70)
The client configuration is
Copy code
val client = HttpClient {
                install(WebSockets) 
            client.webSocket(
                urlString = "<wss://sample.com/websocket>",
            ) {
                for (frame in incoming) {
                    if (frame is Frame.Text) {
                        val messageJson = frame.readText()
                        // log
                    }
                }
            }
a

Aleksei Tirman [JB]

09/25/2023, 6:10 AM
Unfortunately, I cannot reproduce your problem with the following code:
Copy code
val client = HttpClient {
    install(WebSockets)
}
client.webSocket(urlString = "<wss://ws.postman-echo.com/raw>") {
    for (frame in incoming) {
        if (frame is Frame.Text) {
            val messageJson = frame.readText()
        }
    }
}
s

Sudhanshu Singh

09/25/2023, 8:40 AM
I can see that other websockets work. But
client.websocket
throws error when i connect to my websocket. is there anyway to enable TLS so that below error isn't thrown?
Copy code
io.ktor.network.tls.TLSException: Received alert during handshake. Level: FATAL, code: ProtocolVersion
                            	at io.ktor.network.tls.TLSClientHandshake$input$1.invokeSuspend(TLSClientHandshake.kt:70)
I looked through the same issue https://github.com/ktorio/ktor/issues/439 which looks to be fixed. but I am still getting it.
a

Aleksei Tirman [JB]

09/25/2023, 9:05 AM
Can you reproduce the problem with the OkHttp engine?
s

Sudhanshu Singh

09/25/2023, 9:06 AM
oh thanks. OkHttp engine works. will use that 🙂