Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QNetworkReply not emitting finished signal



  • 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.


  • Moderators

    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



  • @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.



  • 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)



  • 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.



  • @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?



  • @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.


Log in to reply