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 not emitting finished signal
QtWS25 Last Chance

QNetworkReply not emitting finished signal

Scheduled Pinned Locked Moved Unsolved General and Desktop
qnetworkreplyfinished
7 Posts 4 Posters 2.6k 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.
  • Y Offline
    Y Offline
    yourMessiah
    wrote on last edited by
    #1

    Below is a snippet of code from my project. When QUrl consists of the string ( i.e. the url) http://www.youtube.com/api/timedtext?v=2xrsRlWmcRQ&lang=en&name=NPTEL Official&fmt=ttml&xorb=2&xobt=3&xovt=3 , netReply 's finished signal is never emitted. I have verified this by setting debugging points in the corresponding slot.
    netReply is a pointer of type QNetworkReply
    readyRead and downloadProgress signals are also never emitted.

    void study::searchRequest(QUrl url)
    {
        QNetworkRequest request;
        request.setHeader(QNetworkRequest::UserAgentHeader,QVariant(QString("EdAssist-Qt")));
        request.setUrl(url);
        netReply=netManager->get(request);
    
        statusBar->show();
        webViewProgressBar->show();
        connect(netReply,&QNetworkReply::finished,this,&study::networkRequestFinished);
        connect(netReply,&QIODevice::readyRead,this,&study::networkDataReady);
        connect(netReply,&QNetworkReply::downloadProgress,this,&study::networkDataFetching);
    
        return ;
    }
    

    The request never leaves my application because i don't see any HTTP requests in my wireshark capture.
    I am having a very hard time debugging this, if someone could give me some pointers I will be grateful.

    J.HilkJ Pablo J. RoginaP 2 Replies Last reply
    0
    • Y yourMessiah

      Below is a snippet of code from my project. When QUrl consists of the string ( i.e. the url) http://www.youtube.com/api/timedtext?v=2xrsRlWmcRQ&lang=en&name=NPTEL Official&fmt=ttml&xorb=2&xobt=3&xovt=3 , netReply 's finished signal is never emitted. I have verified this by setting debugging points in the corresponding slot.
      netReply is a pointer of type QNetworkReply
      readyRead and downloadProgress signals are also never emitted.

      void study::searchRequest(QUrl url)
      {
          QNetworkRequest request;
          request.setHeader(QNetworkRequest::UserAgentHeader,QVariant(QString("EdAssist-Qt")));
          request.setUrl(url);
          netReply=netManager->get(request);
      
          statusBar->show();
          webViewProgressBar->show();
          connect(netReply,&QNetworkReply::finished,this,&study::networkRequestFinished);
          connect(netReply,&QIODevice::readyRead,this,&study::networkDataReady);
          connect(netReply,&QNetworkReply::downloadProgress,this,&study::networkDataFetching);
      
          return ;
      }
      

      The request never leaves my application because i don't see any HTTP requests in my wireshark capture.
      I am having a very hard time debugging this, if someone could give me some pointers I will be grateful.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by J.Hilk
      #2

      hi @yourMessiah and welcome

      step one, connect the error signals of QNetworkReply and QNetworkaccessManager to a slot and see if those are triggered

      step two look for infinite loops in your code and remove them


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      Y 1 Reply Last reply
      6
      • Y yourMessiah

        Below is a snippet of code from my project. When QUrl consists of the string ( i.e. the url) http://www.youtube.com/api/timedtext?v=2xrsRlWmcRQ&lang=en&name=NPTEL Official&fmt=ttml&xorb=2&xobt=3&xovt=3 , netReply 's finished signal is never emitted. I have verified this by setting debugging points in the corresponding slot.
        netReply is a pointer of type QNetworkReply
        readyRead and downloadProgress signals are also never emitted.

        void study::searchRequest(QUrl url)
        {
            QNetworkRequest request;
            request.setHeader(QNetworkRequest::UserAgentHeader,QVariant(QString("EdAssist-Qt")));
            request.setUrl(url);
            netReply=netManager->get(request);
        
            statusBar->show();
            webViewProgressBar->show();
            connect(netReply,&QNetworkReply::finished,this,&study::networkRequestFinished);
            connect(netReply,&QIODevice::readyRead,this,&study::networkDataReady);
            connect(netReply,&QNetworkReply::downloadProgress,this,&study::networkDataFetching);
        
            return ;
        }
        

        The request never leaves my application because i don't see any HTTP requests in my wireshark capture.
        I am having a very hard time debugging this, if someone could give me some pointers I will be grateful.

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @yourMessiah
        step three: capture network traffic (i.e. Wireshark tool) to see what your Qt app is actually sending to that URL and what is receiving, if any.

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        Y 1 Reply Last reply
        3
        • J.HilkJ J.Hilk

          hi @yourMessiah and welcome

          step one, connect the error signals of QNetworkReply and QNetworkaccessManager to a slot and see if those are triggered

          step two look for infinite loops in your code and remove them

          Y Offline
          Y Offline
          yourMessiah
          wrote on last edited by
          #4

          hi @J-Hilk neither the error signal of QNetworkReply is being emitted nor is the finished signal of QNetworkAccessManager is being emitted.
          I am using a single instance of QNetworkAccessManager throughout my application. I declared it in main.cpp and passed its reference to every class needing network access.
          From one class I am accessing i.ytimg.com and that is working fine.

          I could not find any infinite loops in my application. (If infinite loops existed wouldn't they lead to high CPU usage? I don't experience that when running my application)

          1 Reply Last reply
          0
          • Kent-DorfmanK Offline
            Kent-DorfmanK Offline
            Kent-Dorfman
            wrote on last edited by
            #5

            netReply finished signal is dependent upon the version of the HTTP server you are communicating with. Read the specs on the difference between versions of HTTP. The older version will work and the newer one will probably NOT emit the signal based on the code you provide.

            finished would be emitted when the remote closes the connection. On the newer version the semantics of who closes the session have changed.

            Y 1 Reply Last reply
            0
            • Pablo J. RoginaP Pablo J. Rogina

              @yourMessiah
              step three: capture network traffic (i.e. Wireshark tool) to see what your Qt app is actually sending to that URL and what is receiving, if any.

              Y Offline
              Y Offline
              yourMessiah
              wrote on last edited by
              #6

              @Pablo-J-Rogina
              Queries to a local server return fine.
              loopbackTestPost.png

              I have a aws server running at 3.6.118.100 under the domain mightymaharaja.tk. When i pass the URL as http://3.6.118.100/ (to searchRequest function) the server returns a response but netReply doesn't emit finished.
              myServerIpTestPost.png

              This is when the url is http://mightymaharaja.tk. It doesn't send the HTTP request.
              myServerNameTestPost.png

              This is when the url is https://qt.io. The finished signal is still not emitted.
              qt_ioTestPost.png

              Note : I am using Qt 5.12.6 . Should i upgrade to 5.14?

              1 Reply Last reply
              0
              • Kent-DorfmanK Kent-Dorfman

                netReply finished signal is dependent upon the version of the HTTP server you are communicating with. Read the specs on the difference between versions of HTTP. The older version will work and the newer one will probably NOT emit the signal based on the code you provide.

                finished would be emitted when the remote closes the connection. On the newer version the semantics of who closes the session have changed.

                Y Offline
                Y Offline
                yourMessiah
                wrote on last edited by yourMessiah
                #7

                @Kent-Dorfman Everything was actually working fine until 2 days ago when I made some changes to my code.
                So the problem is probably not related to the HTTP version.

                1 Reply Last reply
                0

                • Login

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