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

QNetworkReply Socket TimeoutError

    XMLWordPrintable

    Details

    • Platform/s:
      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
          66 kB
          Remik Ziemlinski
        2. fail.txt
          9 kB
          Remik Ziemlinski
        3. lucky.png
          68 kB
          Remik Ziemlinski
        4. lucky.txt
          5 kB
          Remik Ziemlinski
        5. SocketTimeout.zip
          9 kB
          Remik Ziemlinski
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            tpochep Timur Pocheptsov
            Reporter:
            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