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 Error Timeout

QNetworkReply Error Timeout

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 6.3k 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.
  • H Offline
    H Offline
    Hornsj2
    wrote on 1 Nov 2011, 19:17 last edited by
    #1

    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;
    }
    }
    }@

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 1 Nov 2011, 21:17 last edited by
      #2

      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.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hornsj2
        wrote on 2 Nov 2011, 14:46 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on 3 Nov 2011, 00:00 last edited by
          #4

          Sounds reasonable. The actual error (if any) depends on the conditions of the interface, the behavior of the operating system, etc.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • H Offline
            H Offline
            Hornsj2
            wrote on 3 Nov 2011, 13:39 last edited by
            #5

            QNetworkReply::UnknownNetworkError being the only error generated by the QNetworkReply, regardless of the actual error, is working as intended? Weird.

            1 Reply Last reply
            0

            1/5

            1 Nov 2011, 19:17

            • Login

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