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 869 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.
  • K Offline
    K Offline
    Kutyus
    wrote on 3 May 2023, 07:29 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.

    J 1 Reply Last reply 3 May 2023, 08:48
    0
    • K Offline
      K Offline
      Kutyus
      wrote on 4 May 2023, 13:25 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
      • K Kutyus
        3 May 2023, 07:29

        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.

        J Offline
        J Offline
        JonB
        wrote on 3 May 2023, 08:48 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.

        K 1 Reply Last reply 3 May 2023, 11:01
        0
        • J JonB
          3 May 2023, 08:48

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

          K Offline
          K Offline
          Kutyus
          wrote on 3 May 2023, 11:01 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.

          J 1 Reply Last reply 3 May 2023, 12:14
          0
          • K Kutyus
            3 May 2023, 11:01

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

            J Offline
            J Offline
            JonB
            wrote on 3 May 2023, 12:14 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
            • K Offline
              K Offline
              Kutyus
              wrote on 4 May 2023, 13:25 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
              • K Kutyus has marked this topic as solved on 4 May 2023, 13:25

              1/5

              3 May 2023, 07:29

              • Login

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