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

[REG 5.13.1 -> 5.14] QNetworkAccessManager::get() fails with UnknownNetworkError when VPN is connected



    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Duplicate
    • Affects Version/s: 5.14.0, 5.14.2
    • Fix Version/s: 5.14.2
    • Component/s: Network
    • Labels:
    • Environment:
      Windows 8.1, Windows 10 1909, OpenVPN 2.4.7
    • Platform/s:
    • Commits:
    • Story Points:
    • Sprint:
      Qt6_Foundation_ Sprint 3


      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).


        1. NLMTest.exe
          9 kB
        2. NLMTest.PNG
          42 kB

          Issue Links

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



              manordheim Mårten Nordheim
              cgutman Cameron Gutman
              PM Owner:
              Maurice Kalinowski
              2 Vote for this issue
              4 Start watching this issue



                  Gerrit Reviews

                  There are no open Gerrit changes