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. QWebSocket::ping() Does Not Work
Forum Updated to NodeBB v4.3 + New Features

QWebSocket::ping() Does Not Work

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.2k Views 2 Watching
  • 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.
  • Hongbao ChenH Offline
    Hongbao ChenH Offline
    Hongbao Chen
    wrote on last edited by Hongbao Chen
    #1

    Hello, people

    I call QWebSocket::ping() to ping the server (netty 4.1) but no data sent after the ping(). No data sent to the server (checked from the resource monitor on Windows 10), and the server did not receive any neither.

    Then I ran the code to call ping() some times and finally got only one piece of pong returned, on localhost with over 3700 milliseconds elapsed.

    I clone the git and navigate to the testing code:
    qtwebsockets\tests\auto\websockets\qwebsocket\tst_qwebsocket.cpp

    Tried to locate the ping() test but found nothing. I think the ping() may not be tested?

    Can anyone tell me if the ping() worked or buggy, or I need to do more to get it work?

    Pablo J. RoginaP 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should check your network activity using something like Wireshark to see what's going on on that side.

      You should also add which version of Qt you are using.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      Hongbao ChenH 1 Reply Last reply
      3
      • Hongbao ChenH Hongbao Chen

        Hello, people

        I call QWebSocket::ping() to ping the server (netty 4.1) but no data sent after the ping(). No data sent to the server (checked from the resource monitor on Windows 10), and the server did not receive any neither.

        Then I ran the code to call ping() some times and finally got only one piece of pong returned, on localhost with over 3700 milliseconds elapsed.

        I clone the git and navigate to the testing code:
        qtwebsockets\tests\auto\websockets\qwebsocket\tst_qwebsocket.cpp

        Tried to locate the ping() test but found nothing. I think the ping() may not be tested?

        Can anyone tell me if the ping() worked or buggy, or I need to do more to get it work?

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by Pablo J. Rogina
        #3

        @Hongbao-Chen said in QWebSocket::ping() Does Not Work:

        no data sent after the ping()

        Are you providing a custom payload? From ping() documentation:

        Pings the server to indicate that the connection is still alive. Additional payload can be sent along the ping message.
        The size of the payload cannot be bigger than 125. If it is larger, the payload is clipped to 125 bytes.

        As @SGaist mentioned, you should check network traffic capture to confirm what your QWebSocket is sending and receiving...

        From source code for QWebSocket::ping() it should send some.

        In addition, are you sure the server does actually properly implement the ping/pong schema?
        You may need to try another different server just in case to rule out the server end.

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        Hongbao ChenH 1 Reply Last reply
        2
        • SGaistS SGaist

          Hi and welcome to devnet,

          You should check your network activity using something like Wireshark to see what's going on on that side.

          You should also add which version of Qt you are using.

          Hongbao ChenH Offline
          Hongbao ChenH Offline
          Hongbao Chen
          wrote on last edited by
          #4

          @SGaist Thank you for you reply. I think I have found the possible cause that the ping() is called from another thread other than where QWebSocket is allocated.

          1 Reply Last reply
          1
          • Pablo J. RoginaP Pablo J. Rogina

            @Hongbao-Chen said in QWebSocket::ping() Does Not Work:

            no data sent after the ping()

            Are you providing a custom payload? From ping() documentation:

            Pings the server to indicate that the connection is still alive. Additional payload can be sent along the ping message.
            The size of the payload cannot be bigger than 125. If it is larger, the payload is clipped to 125 bytes.

            As @SGaist mentioned, you should check network traffic capture to confirm what your QWebSocket is sending and receiving...

            From source code for QWebSocket::ping() it should send some.

            In addition, are you sure the server does actually properly implement the ping/pong schema?
            You may need to try another different server just in case to rule out the server end.

            Hongbao ChenH Offline
            Hongbao ChenH Offline
            Hongbao Chen
            wrote on last edited by
            #5

            @Pablo-J.-Rogina Thank you for your reply. The netty has built-in mechanism for answering a ping frame. I think it is because I call the ping() from another thread other than where QWebSocket is allocated.

            1 Reply Last reply
            0

            • Login

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