QWebSocket::ping() Does Not Work
-
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.cppTried 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?
-
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.cppTried 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?
@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. -
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.
@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.
-
@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.@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.