Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Setting QWebsocket SO_KEEPALIVE parameters
Forum Updated to NodeBB v4.3 + New Features

Setting QWebsocket SO_KEEPALIVE parameters

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 882 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • KutyusK Offline
    KutyusK Offline
    Kutyus
    wrote on last edited by
    #1

    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.

    JonBJ 1 Reply Last reply
    0
    • KutyusK Offline
      KutyusK Offline
      Kutyus
      wrote on last edited by
      #5

      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 Reply Last reply
      0
      • KutyusK Kutyus

        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.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @Kutyus
        I have not used QWebSocket, but inspecting the sources shows its uses of QTcpSocket are hidden away in private variables/methods.

        I only know of void QWebSocketServer::handleConnection(QTcpSocket *socket) const, that's at the websocket server side.

        KutyusK 1 Reply Last reply
        0
        • JonBJ JonB

          @Kutyus
          I have not used QWebSocket, but inspecting the sources shows its uses of QTcpSocket are hidden away in private variables/methods.

          I only know of void QWebSocketServer::handleConnection(QTcpSocket *socket) const, that's at the websocket server side.

          KutyusK Offline
          KutyusK Offline
          Kutyus
          wrote on last edited by
          #3

          @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.

          JonBJ 1 Reply Last reply
          0
          • KutyusK Kutyus

            @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.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @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.

            1 Reply Last reply
            0
            • KutyusK Offline
              KutyusK Offline
              Kutyus
              wrote on last edited by
              #5

              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 Reply Last reply
              0
              • KutyusK Kutyus has marked this topic as solved on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved