Setting QWebsocket SO_KEEPALIVE parameters
-
wrote on 3 May 2023, 07:29 last edited by
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.
-
wrote on 4 May 2023, 13:25 last edited by
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.
wrote on 3 May 2023, 08:48 last edited by@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.
wrote on 3 May 2023, 11:01 last edited by@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. -
@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.wrote on 3 May 2023, 12:14 last edited by@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. -
wrote on 4 May 2023, 13:25 last edited by
Based on this, I managed to solve it: https://forum.qt.io/topic/106382/how-to-check-server-life-using-qwebsocket-ping-pong?_=1683206587457
-
1/5