QNetworkReply not emitting finished signal
-
wrote on 13 Mar 2020, 08:17 last edited by
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. -
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.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
-
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.wrote on 13 Mar 2020, 17:54 last edited by@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 @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
wrote on 14 Mar 2020, 05:34 last edited byhi @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)
-
wrote on 14 Mar 2020, 05:59 last edited by
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.
-
@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.wrote on 14 Mar 2020, 06:23 last edited by@Pablo-J-Rogina
Queries to a local server return fine.
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.
This is when the url is http://mightymaharaja.tk. It doesn't send the HTTP request.
This is when the url is https://qt.io. The finished signal is still not emitted.
Note : I am using Qt 5.12.6 . Should i upgrade to 5.14?
-
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.
wrote on 14 Mar 2020, 06:58 last edited by yourMessiah@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.
7/7