Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QNetworkAccessManager preventing localhost connection

    General and Desktop
    2
    4
    964
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • jhiatt
      jhiatt last edited by

      We have a QML application which fetches image assets from a local web server. However, the Qt bearer management plugins seem to be interfering with this process. If the network is determined to be "NotAccessible" (e.g. no wifi network is up) then any call through the QNetworkAccessManager will fail. I believe this is the condition we're hitting: https://github.com/qt/qtbase/blob/5.7.1/src/network/access/qnetworkaccessmanager.cpp#L1166

      As we're trying to make an HTTP call to localhost, we don't care about connectivity to the wider Internet, but our requests are getting blocked regardless.

      I've only been able to reproduce this issue on Linux, specifically with the connman bearer management integration. I don't know if the NetworkManager integration will do the same thing, but I was NOT able to reproduce it on Mac OS; no matter what I tried the network was never marked NotAccessible.

      The only workaround I have is to compile Qt with -no-feature-bearermanagement to turn it off completely.

      Is there any way to disable it programatically if it was enabled at compile time? I haven't found any way to override this behavior. Setting an invalid empty QNetworkConfiguration() doesn't fix the problem, despite some notes in the documentation that suggested otherwise. I also don't see anyway to inject a fake network configuration that would cause the request to proceed, as the fields I would have to set are marked private. It looks like overriding QNetworkAccessManager::createRequest() in a subclass might be an option, but it's unclear that in the subclass I could invoke all the standard superclass behavior except for the bearer management stuff.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Pretty interesting case. Did you already check the bug report system ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • jhiatt
          jhiatt last edited by

          Hi @SGaist ,

          I did some searches in the bug tracker but so far haven't found anything matching my use case.

          I came across this StackOverflow post that looks like the same problem. It doesn't look like that poster was able to find any resolution.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Then you should open a new report about this providing all the information you have as well as link to relevant material.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • First post
              Last post