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. QNetworkReply do not have any progress(no reply from server), how should I deal with it?

QNetworkReply do not have any progress(no reply from server), how should I deal with it?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 851 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.
  • thamT Offline
    thamT Offline
    tham
    wrote on last edited by tham
    #1

    Qt5.6.2
    compiler : msvc 2015 64bits

    Trying to scrape images from google search, after I obtain all of the links of the images and start to download them, sometimes servers take a long time to respond or even "refuse" to response, in that case, the app will hang at there unless I setup a timer to monitor the progress of network reply as before(if it takes too long to reply, restart the download or abort it). This solution got a problem ,I have to setup the waiting time manually, and I have no idea how many seconds I should wait because I have no control on different environments.

    I start the download like this

    task->network_reply_ = network_access_->get(task->network_request_);
    connect(task->network_reply_, static_cast<void(QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error), this, &download_supervisor::error_handle);
    connect(task->network_reply_, &QNetworkReply::readyRead, this, &download_supervisor::ready_read);
    connect(task->network_reply_, static_cast<void(QNetworkReply::*)()>(&QNetworkReply::finished), this, &download_supervisor::process_download_finished);
    connect(task->network_reply_, &QNetworkReply::downloadProgress, this,&download_supervisor::handle_download_progress);
    connect(task->network_reply_, static_cast<void(QNetworkReply::*)()>(&QNetworkReply::finished),task->network_reply_, &QNetworkReply::deleteLater);
    

    Network request similar to

    QNetworkRequest request(url);
    QString const header = "Googlebot-Image/1.0";
    request.setHeader(QNetworkRequest::UserAgentHeader, header);
    

    By the way, whole project place at github, I always want an app to help me download the images by google, bing, flickr search for computer vision projects.

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

      Hi,

      Sounds like you should gather some statistics about the timeout you experience from your machine and then try to calculate a good values to use.

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

      1 Reply Last reply
      2
      • Venkatesh VV Offline
        Venkatesh VV Offline
        Venkatesh V
        wrote on last edited by
        #3

        Hi..
        My suggestion in this is, By using QTimer you can overcome from your issue.
        take a Qtimer instance set some certain interval, after the request start the timer and once the timer emits timeout connect it to another slot and check the reply came or not(do it for some time). if the reply came within that period then stop the timer and get the reply, if not again check after timer next interval. within 3 interval you not get a reply then better to abort the request and try again by request the same image.

        1 Reply Last reply
        2

        • Login

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