Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QNetworkAccessManager preventing localhost connection
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.
Pretty interesting case. Did you already check the bug report system ?
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.
Then you should open a new report about this providing all the information you have as well as link to relevant material.