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 takes long time to emit finished signal
QtWS25 Last Chance

QNetworkReply takes long time to emit finished signal

Scheduled Pinned Locked Moved Solved General and Desktop
qnetworkreplyqnetworkrequestqt5delayheader
7 Posts 2 Posters 4.2k Views
  • 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.
  • T Offline
    T Offline
    Tusharh
    wrote on 20 Oct 2015, 13:11 last edited by A Former User 8 May 2016, 15:36
    #1

    I am trying to read a header value from reply for which I had fired a request. First, it didn't use to give any reply.Later,I added an event loop to know when the Finished signal is received. I now, get the reply properly,but problem now I am facing is that it takes huge time to reply. Nearly 10 seconds..!!! I receive the reply immediately after firing the request.I can see it in fiddler(a packet capturing tool). Why is it taking 10 seconds when it has all the values?

    my chunk of code -

    bool MySampleApp::getStatus()
    {
    QNetworkRequest request;
    QUrl url ("http://www.myapp.com");
    QString strQuery = "myquerytoserver";
    url.setEncodedQuery(strQuery.toUtf8());
    request.setUrl();
    m_networkManager = new QNetworkAccessManager(this);
    request.setSslConfiguration(this->createSslConfig());
    QNetworkReply *reply = m_networkManager->sendCustomRequest(request,"HEAD");

    QEventLoop loop;
    connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); //10 seconds??? why??
    loop.exec();
    
     if(reply)
    {
       reply->deleteLater();
       QByteArray strPresent =  reply->rawHeader("is_present"); // my custom header value sent by server
       if("true" == strPresent)
          return true;
    }
    return false;
    

    }

    Thanks in advance..!!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Oct 2015, 21:26 last edited by
      #2

      Hi,

      Are you sure that all data have arrived that soon ? Getting the headers and getting everything that the request has asked for are two different things

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

      T 1 Reply Last reply 21 Oct 2015, 04:37
      0
      • S SGaist
        20 Oct 2015, 21:26

        Hi,

        Are you sure that all data have arrived that soon ? Getting the headers and getting everything that the request has asked for are two different things

        T Offline
        T Offline
        Tusharh
        wrote on 21 Oct 2015, 04:37 last edited by
        #3

        @SGaist Yes.I immediately get all the data in the response/reply. But, here as I mentioned it takes huge time to emit finished. When multiple requests are fired, their 10 seconds adding up literally hangs up my app.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 21 Oct 2015, 19:54 last edited by
          #4

          Does the server keep the connection open too long ?

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

          T 1 Reply Last reply 22 Oct 2015, 05:33
          0
          • S SGaist
            21 Oct 2015, 19:54

            Does the server keep the connection open too long ?

            T Offline
            T Offline
            Tusharh
            wrote on 22 Oct 2015, 05:33 last edited by
            #5

            @SGaist No,server doesn't keep connection open to long. Does it have to do something with networkacessmanager? It's used through out the app & some requests have timers associated with them. But, I don't use timer for my this particular request.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 22 Oct 2015, 20:33 last edited by
              #6

              How many queries are you sending at the same time ?

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

              T 1 Reply Last reply 27 Oct 2015, 04:24
              0
              • S SGaist
                22 Oct 2015, 20:33

                How many queries are you sending at the same time ?

                T Offline
                T Offline
                Tusharh
                wrote on 27 Oct 2015, 04:24 last edited by
                #7

                @SGaist Hi, I resolved the issue. I was actually firing sendCustomRequest() api as I was using a specific url query in request which was needed in to fire via HEAD method. Before firing sendCustomRequest() api I was also creating & resetting my ssl configuration. So, instead I directly now use the head() api to fire my HEAD request. Now,finished signal by reply gets fired instantaneously & I am able to read my specific header value in response in no time.

                Thanks for your time..!! :)

                1 Reply Last reply
                0

                1/7

                20 Oct 2015, 13:11

                • Login

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