Details
Description
After updating my application to Qt 5.14.0, I received several user reports with logs showing that every one of my QNetworkRequests was immediately failing with QNetworkReply::UnknownNetworkError even though the system had Internet connectivity. When users tested a Qt 5.13.1-based version side-by-side with the 5.14.0-based version, it had no trouble making network requests.
I was able to reproduce this issue using a OpenVPN connection configured to tunnel all network traffic through (though other users claim to experience this without a VPN at all). Looking through the Qt code, I discovered https://codereview.qt-project.org/c/qt/qtbase/+/258916/16 which seems to be the CL that introduced the bug.
The problem I see in my repro is that INetworkListManager::GetConnectivity() is returning (NLM_CONNECTIVITY_IPV4_LOCALNETWORK | NLM_CONNECTIVITY_IPV6_LOCALNETWORK), so QNetworkAccessManager believes the network is inaccessible. Interestingly, when I enter Network and Sharing Center, it shows my VPN with "Local connectivity" (which is wrong) and my WiFi connection with "Internet connectivity", so I'm not sure why INetworkListManager::GetConnectivity() is reporting that the system as a whole only has local connectivity. This seems like a bug in Windows to me. I would suspect that if you went NIC-by-NIC and used INetworkConnection::GetConnectivity(), you'd probably see NLM_CONNECTIVITY_IPV4_INTERNET as expected (since that's likely what Network and Sharing Center is doing).
I was able to confirm this by running the example code from https://stackoverflow.com/questions/17648194/how-can-i-start-my-application-when-network-connection-is-available while OpenVPN was connected.
All of that said, my app makes network requests to hosts on the local subnet, so lack of Internet connectivity should not prevent me from issuing network requests with QNetworkAccessManager. It looks like there was an attempt to handle this case by looking for (NLM_CONNECTIVITY_IPV4_SUBNET | NLM_CONNECTIVITY_IPV6_SUBNET), but I'm not seeing those ever get returned from INetworkListManager::GetConnectivity() in practice. When I disconnect the WAN connection from my router, I get (NLM_CONNECTIVITY_IPV4_LOCALNETWORK | NLM_CONNECTIVITY_IPV6_LOCALNETWORK).
Perhaps the correct solution here is to simply add (NLM_CONNECTIVITY_IPV4_LOCALNETWORK | NLM_CONNECTIVITY_IPV6_LOCALNETWORK) to the flags in QNetworkStatusMonitor::isNetworkAccessible() and QNetworkConnectionMonitor::isReachable() as synonyms to (NLM_CONNECTIVITY_IPV4_SUBNET | NLM_CONNECTIVITY_IPV6_SUBNET).
Attachments
Issue Links
- depends on
-
QTBUG-84907 Remove network gatekeeping
-
- Closed
-
For Gerrit Dashboard: QTBUG-80947 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
290146,2 | QNetConMonitor(Win): Account for LOCALNETWORK reachability | 5.14 | qt/qtbase | Status: MERGED | +2 | 0 |