QNetworkReply Error Timeout
-
wrote on 1 Nov 2011, 19:17 last edited by
I'm using a QNetworkAccessManager to create a QNetwork reply via a post.
I then connect the error signal of the QNetworkReply to a slot which I am going to use to handle errors.
The error I am testing for right now is QNetworkReply::TimeoutError.
I start my application and then unplug the ethernet cable. The post is sent and the QNetworkReply is generated but the QNetworkReply::TimoutError is never sent.
Can anyone tell me what I'm doing wrong?
Send the post
@QNetworkReply* reply = m_app->sendRequestList(m_request, m_configPrefs->password().toStdString());
connect(reply, SIGNAL(finished()), this, SLOT(checkReply()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(replyError(QNetworkReply::NetworkError)));@Error Handler
@void XmlPost::replyError(QNetworkReply::NetworkError errorCode)
{
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
switch(errorCode)
{
case QNetworkReply::TimeoutError:
{
m_requestList.remove(QString::fromStdString(m_request));
reply->deleteLater();
finished();
}
default:
{
break;
}
}
}@ -
wrote on 1 Nov 2011, 21:17 last edited by
In case you pull the network cable, the interface usually goes down. You should check for other errors too, it's very likely that you get something like "no route to host" or something similar.
-
wrote on 2 Nov 2011, 14:46 last edited by
I occasionally get a QNetworkReply::UnknownNetworkError but that is the *ONLY * error which is ever reported by the error signal.
I am using 4.7.4.
-
wrote on 3 Nov 2011, 00:00 last edited by
Sounds reasonable. The actual error (if any) depends on the conditions of the interface, the behavior of the operating system, etc.
-
wrote on 3 Nov 2011, 13:39 last edited by
QNetworkReply::UnknownNetworkError being the only error generated by the QNetworkReply, regardless of the actual error, is working as intended? Weird.
1/5