Hi how can we setup tcp keepalive for WebSocket Se...
# ktor
c
Hi how can we setup tcp keepalive for WebSocket Server on ktor?
a
Unfortunately, that's not possible but you can configure a server to periodically send Websockets ping frames https://ktor.io/docs/websocket.html#configure. Could you please describe your problem in more detail?
c
Thanks @Aleksei Tirman [JB] I found the reason. 1. As you mentioned, I should configure pingPeriod 2. And my server is designed to send some data sometimes after connection is established. So it means my server doesn't need to have any process of incoming data from clients. So I didn't add codes for incoming channel. But it's necessary to define usage of incoming channel. Even if there isn't any own process for incoming data, we should add codes like this. try { incoming.consumeEach { _ -> } } finally { } If we don't add these empty code then the connection is closed soon after connection. I think ping packets also comes from incoming channel. So it's necessary to add the codes. After that the connections keep alive.
WDYT, @Aleksei Tirman [JB]? Makes sense?
a
Yes, you are right.
🙌 1
117 Views