I am trying to connect to our websocket and get I ...
# ktor
s
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
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
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
Can you reproduce the problem with the OkHttp engine?
s
oh thanks. OkHttp engine works. will use that 🙂