Setting QWebsocket SO_KEEPALIVE parameters
-
Hello!
Is it possible to set the TCP connection parameters for QWebsocket? I couldn't find a method that would return the socket handle, and I would need to set the so_keepalive parameters to detect when the connection is lost.
Thank you in advance for your answers.
-
Based on this, I managed to solve it: https://forum.qt.io/topic/106382/how-to-check-server-life-using-qwebsocket-ping-pong?_=1683206587457
-
Hello!
Is it possible to set the TCP connection parameters for QWebsocket? I couldn't find a method that would return the socket handle, and I would need to set the so_keepalive parameters to detect when the connection is lost.
Thank you in advance for your answers.
@Kutyus
I have not usedQWebSocket
, but inspecting the sources shows its uses ofQTcpSocket
are hidden away in private variables/methods.I only know of void QWebSocketServer::handleConnection(QTcpSocket *socket) const, that's at the websocket server side.
-
@Kutyus
I have not usedQWebSocket
, but inspecting the sources shows its uses ofQTcpSocket
are hidden away in private variables/methods.I only know of void QWebSocketServer::handleConnection(QTcpSocket *socket) const, that's at the websocket server side.
-
@JonB
I found this too, but I can't set this parameter not for the QWebsocketSever, but for the QWebsocket, the client, so if the network is interrupted, e.g. I unplug the lan cable, the client is still there in the connected state until the end of time.@Kutyus
Yep, or at least till some timeout closes the socket. In my experience keep alive is dodgy anyway. And is as likely to keep alive what should be dead connections as to maintain what should be live ones. You could even implement your own "keep alive" protocol in your web socket server<->client, though I wouldn't recommend it. Anyway, that's all I know. -
Based on this, I managed to solve it: https://forum.qt.io/topic/106382/how-to-check-server-life-using-qwebsocket-ping-pong?_=1683206587457
-
K Kutyus has marked this topic as solved on