QNetworkAccessManager causes network traffic spike every 5 seconds in wireless network
-
Previously I asked a similar question on network traffic spike every 5 seconds in wireless network. At that time I thought it's caused by QWebKit. Later I created a small download program - actually I only instantiate QNetworkAccessManager and don't do anything with it. The program causes 'pinging' the router to take more than 100 ms every 5 seconds. When the program does not run, the pinging takes less than 1 ms.
I used WireShack to check the packet and it seems the program tried to resolve some address. I don't why it does that and how to stop it.
-
Hi and welcome to devnet,
You should also add which version of Qt you are using and on what OS.
Without a code sample on how you are using QNetworkAccessManager, it's impossible to help you search a solution
-
Thanks for your reply. I just tested on 64bit Windows 7 with Qt 5.3. Here is the code (same for earlier releases like 4.8):
@
int main(int argc, char *argv[])
{
QNetworkAccessManager manager;QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();
}
@
Here is pinging results with the program is running:
@
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time=74ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time=1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
Reply from 10.144.55.2: bytes=32 time=1ms TTL=255
Reply from 10.144.55.2: bytes=32 time=1ms TTL=255
Reply from 10.144.55.2: bytes=32 time=29ms TTL=255
Reply from 10.144.55.2: bytes=32 time=1ms TTL=255
Reply from 10.144.55.2: bytes=32 time=59ms TTL=255
@
When I stopped the program, the pinging result is always
@
Reply from 10.144.55.2: bytes=32 time<1ms TTL=255
@
I figure QNetworkAccessManager tries to contact the server to resolve address but I don't know how to stop it.BTW, I also tried dynamically created QNetworkAccessManager and deleted it after a few minutes. It proves QNetworkAccessManager caused the ping delay.
Thanks.
-
BTW, Qt example: fancybrowser and browser have the same behavior.
-
The first thing that strikes me is that you are creating the QNAM before the QApplication, which is wrong. QApplication must always be created first to allow proper library initialization.
-
Thanks for helping. I switched the sequence of QNAM and QAPP. The results are the same.
-
You can try to use "Wireshark":http://www.wireshark.org/ to monitor the network activity.
[EDIT] I don't see any abnormal network activity when the example app is running. But there is no wireless interface on my computer.
-
The issue appears in wireless environment only. Thanks for your comments.