Results 1 to 3 of 3

Thread: QNetworkAccessManager not able to connect after computer wakes up

  1. #1
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QNetworkAccessManager not able to connect after computer wakes up

    Hello,

    I have seen a peculiar problem with QNetworkAccessManager not being able to connect after my computer comes back from sleep mode. This is the setup, I have an application that uses QNetworkAccessManager to connect to a website every 60 seconds. Everything works great. But if the computer goes to sleep for a long time. When it wakes up it does not work. QNetworkAccessManager never emits any signals. I have tested on Windows XP, Windows Vista.

    I found out that there is a problem with the Host Lookup code inside the QT framework. I fixed the problem by not using DNS lookup.

    Inside Qt\2010.02.1\qt\src\network\kernel\qhostinfo.cpp(Q HostInfoLookupManager::work()) the new DNS requests are queued up. The problem is that this function never schedules another DNS lookup because toBeLookedUp is the same as the previous request that never finished (line:506). Therefore, QNetworkAccessManager never connects because it is waiting for the DNS lookup to comeback with the ip address of the server. Line:514 schedules the DNS lookup work only if scheduled is not NULL but line:509 sets scheduled to NULL every time.

    Qt Code:
    1. if (!scheduledLookups.isEmpty()) {
    2. // try to start the new ones
    3. QMutableListIterator<QHostInfoRunnable*> iterator(scheduledLookups);
    4. while (iterator.hasNext()) {
    5. QHostInfoRunnable *scheduled = iterator.next();
    6.  
    7. // check if a lookup for this host is already running, then postpone
    8. for (int i = 0; i < currentLookups.size(); i++) {
    9. [B]if (currentLookups.at(i)->toBeLookedUp == scheduled->toBeLookedUp) { //line:506
    10. iterator.remove();
    11. postponedLookups.append(scheduled);
    12. scheduled = 0; //line:509
    13. break;
    14. }[/B]
    15. }
    16.  
    17. [B] if (scheduled && threadPool.tryStart(scheduled)) { //line:514 [/B]
    18. // runnable now running in new thread, track this in currentLookups
    19. iterator.remove();
    20. currentLookups.append(scheduled);
    21. } else if (scheduled) {
    22. // wanted to start, but could not because thread pool is busy
    23. break;
    24. } else {
    25. // was postponed, continue iterating
    26. continue;
    27. }
    28. };
    29. }
    To copy to clipboard, switch view to plain text mode 

    I was wondering if any body has seen this problem before.

  2. #2
    Join Date
    Feb 2007
    Posts
    49
    Thanks
    4
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QNetworkAccessManager not able to connect after computer wakes up

    I have seen it. QNetworkAccessManager sometimes works, sometimes doesn't after waking (Windows 7 here). Like you said, it's just never sends any signal.

    Did you reported bug to the Nokia?

  3. #3
    Join Date
    Apr 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QNetworkAccessManager not able to connect after computer wakes up

    Yes I did report it to Nokia. This is what they told me.

    QTBUG-10286.
    ----------------------------------

    Resolution: Incomplete

    We've done some bugfixes in work() in the last days.
    Can you please test with a Qt compiled from http://qt.gitorious.org/qt/qt/commits/4.6 ? (see the .tar.gz link on the right side).

    I will be testing it with their code from their repo to see if their bug fixes will fix this problem. I will also report what I find here.

Similar Threads

  1. Replies: 16
    Last Post: 16th February 2010, 14:17
  2. Turn off computer
    By swiety in forum KDE Forum
    Replies: 1
    Last Post: 5th January 2008, 16:40
  3. running Qt application on computer without Qt
    By vonCZ in forum Installation and Deployment
    Replies: 2
    Last Post: 30th May 2007, 16:36
  4. Replies: 4
    Last Post: 10th November 2006, 16:38

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.