can I configure websocket client ping periods and ...
# ktor
n
can I configure websocket client ping periods and timeouts? websocket client described here https://ktor.io/clients/websockets.html
To use this feature, you need to include io.ktor:ktor-client-websocket artifact.
📝 1
1
d
I think it is not possible in 0.9.2 (at least not while installing it), but let’s confirm it. ^^ @e5l is it possible to configure them?
EDIT: It is possible. Going to update the sample from the page:
Copy code
val ws = client.webSocketSession(method = HttpMethod.Get, host = "127.0.0.1", port = 8080, path = "/route/path/to/ws")
try {
    ws.pingInterval = Duration.ofMinutes(1)
    ws.send(Frame.Text("Hello World"))
} finally {
    ws.close()
}
or
Copy code
val client: HttpClient = HttpClient(...)
<http://client.ws|client.ws>(method = HttpMethod.Get, host = "127.0.0.1", port = 8080, path = "/route/path/to/ws") { // this: WebSocketSession
    (this as DefaultWebSocketSession).pingInterval = Duration.ofMinutes(1)
}
This small inconvenience will be addressed soon
n
thanks. both methods works!
👍 1