Results 1 to 1 of 1

Thread: How my software can catch/avoid "No carrier" response from QNetwork?

  1. #1
    Join Date
    Mar 2019
    Qt products
    Qt5 Qt/Embedded
    Unix/X11 Windows

    Default Re: How my software can catch/avoid "No carrier" response from QNetwork?


    I'm facing a problem when I need to treat some asynchronous requisitions from a service.

    Qt Code:
    1. networkManager = new QNetworkAccessManager(this);
    2. QNetworkRequest request((QUrl (url)));
    3. request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
    4. request.setRawHeader("Cache-Control", "no-cache");
    5. reply = networkManager->post(request, QJsonDocument(body).toJson());
    6. reply = networkManager->get(request);
    8. QObject::connect(networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
    9. QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(replyError(QNetworkReply::NetworkError)));
    To copy to clipboard, switch view to plain text mode 

    Undesirable behavior occurs in situations where network access service is unstable. If the requisition fails, I can handle that and abort the reply. However, sometimes the long latency in response can result in a "long pooling" ways of QNetworkReply that waits for a long time, generating after x seconds the "No carrier" message.

    It's very important to avoid this behavior, trying to catch "No carrier" or with the use of some approach to abort the reply.

    The collateral effects are related to issues in QML interactions and the application can stop working in the worst case because several requests are made for each minute and QNetworkReply allocate each time more threads.

    Mar 14 10:57:49 qt application[12911]: "No carrier"
    Mar 14 10:57:59 qt application[12911]: "No carrier"
    Mar 14 11:09:29 qt application[12911]: "No carrier"
    Mar 14 11:09:39 qt application[12911]: "No carrier"
    Mar 14 11:09:49 qt application[12911]: "No carrier"
    Mar 14 11:36:30 qt application[12911]: "No carrier"
    How I could do to fix that?

    Added after 48 minutes:

    I found an approach and it worked very well.

    Set a timer to the reply is a way to deal with this question. A detailed discussion can be found here:
    Last edited by carpajr; 14th March 2019 at 19:37.

Similar Threads

  1. Replies: 3
    Last Post: 7th October 2015, 10:44
  2. Replies: 1
    Last Post: 5th May 2014, 07:49
  3. Using QEvent to avoid a slot to be called "concurrently"?
    By LisaDearheart in forum Qt Programming
    Replies: 4
    Last Post: 19th August 2012, 19:34
  4. [WebKit] catch "page not found" error
    By maston in forum Qt Programming
    Replies: 3
    Last Post: 16th November 2010, 15:44
  5. Replies: 2
    Last Post: 20th March 2010, 18:22


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.