Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.9.6
-
Windows 7
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).