Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-103259

Calling QNetworkReply::abort causes QNetworkAccessManager to stall when using HTTP Proxy

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/X11
    • Story Points:
      8

      Description

      User contacted Qt Support about following issue:

      "

      We are using a few QNetworkAccessManager (NAM) instances /w and /wo a HTTP Proxy. The connection with a proxy will completely stall when calling QNetworkReply::abort at least 2 times per concurrent connection.

      When a request runs into a timeout, we called QNetworkReply::abort. After a few timeouts (e.g. due to Proxy not reaching target server) this led to the QNetworkAccessManager stalling and not sending new requests to the Proxy. Actually restarting the proxy doesn't solve the issue - NAM remains silent and wont despatch new requests.

      Calling QNetworkReply::close instead solves our issue, but sounds wrong according to the documentation.

      "

      We tested this at Qt Support with:

      #include <QApplication>
      #include <QDebug>
      #include <QNetworkAccessManager>
      #include <QNetworkProxy>
      #include <QNetworkReply>
      #include <QTimer>
      
      int main(int argc, char *argv[])
      {
      QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      QApplication a(argc, argv);
      QNetworkAccessManager m;
      QNetworkProxy proxy;
      proxy.setHostName("localhost");
      proxy.setPort(1337);
      proxy.setType(QNetworkProxy::Socks5Proxy);
      m.setProxy(proxy);
      for (int i = 0; i < 16; ++i) {
      auto first = m.get(QNetworkRequest(QUrl("http://nonexistent")));
      QObject::connect(first, &QNetworkReply::finished, [] { qDebug("nonexistent finished"); });
      QTimer::singleShot(100, [first](){first->abort();});
      }
      QTimer::singleShot(1000, [&m](){
      auto second = m.get(QNetworkRequest(QUrl("http://google.com")));
      QObject::connect(second, &QNetworkReply::finished, []{
      qDebug("google finished");
      });
      });
      return a.exec();
      }
      

      And we never got the "google finished".

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            manordheim MÃ¥rten Nordheim
            Reporter:
            tero.pelkonen Tero Pelkonen
            PM Owner:
            Vladimir Minenko Vladimir Minenko
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes