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

QNetworkReply Socket TimeoutError

    XMLWordPrintable

Details

    • Windows

    Description

      I get an immediate "Socket operation timed out" error on Windows 7 almost always when making a https GET request. My customers get this error on Windows 10 as well.  I narrowed it down to a random connectTimeout.  When it is zero, my request fails, when it is sometimes a positive number it works, and when it is negative, it works too and I get QTimer warnings about negative values because a "connectTimer" uses this value.  The line of code where this random value overrides the default 30 second timeout is in qabstractsocket.cpp near line 1150 (introduced in Qt5.9).  When I remove this overriding code, the requests work perfectly.

      #ifndef QT_NO_BEARERMANAGEMENT
                  QSharedPointer<QNetworkSession> networkSession = qvariant_cast< QSharedPointer<QNetworkSession> >(q->property("_q_networksession"));
                  if (networkSession) {
                      QNetworkConfiguration networkConfiguration = networkSession->configuration();
                      connectTimeout = networkConfiguration.connectTimeout();
                  }
      #endif

      I attached an example program to recreate the error, plus the qDebug output when it fails and when it sometimes works. This fails with the prebuilt commercial Windows binaries for Qt 5.9.6, and with our own local builds with MSVC2017.  The example code has a button to make a Qt request (which fails), and a pure Windows API request (that always works).

      Attachments

        1. fail.png
          fail.png
          66 kB
        2. fail.txt
          9 kB
        3. lucky.png
          lucky.png
          68 kB
        4. lucky.txt
          5 kB
        5. SocketTimeout.zip
          9 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            remik Remik Ziemlinski
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes