Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.9
-
None
Description
When setting the following environment vars to set the proxy (for example):
export no_proxy="192.168.0.1" export http_proxy="http://someproxy:8080"
And then try and open a QWebSocket:
QWebSocket ws; ws.open(QUrl("ws://192.168.0.1/some/url "));
I get a QAbstractSocket::UnsupportedSocketOperationError connection error with error string:
The proxy type is invalid for this operation
The problem is that the hostname is not set on the QNetworkProxyQuery for the underlying QTcpSocket. This causes the check in
static bool ignoreProxyFor(const QNetworkProxyQuery &query)
to fail.
I believe this came in with the following patch : https://codereview.qt-project.org/c/qt/qtbase/+/186124
My fix was to ensure the hostname is set on the QNetworkProxyQuery for QTcpSocket:
--- a/src/network/socket/qnativesocketengine.cpp 2020-06-30 15:26:04.000940714 +0100 +++ b/src/network/socket/qnativesocketengine.cpp 2020-07-03 11:31:28.509814933 +0100 @@ -395,6 +395,8 @@ // QNetworkProxyQuery). QNetworkProxyQuery query; query.setQueryType(queryType); + if (queryType == QNetworkProxyQuery::TcpSocket) + query.setPeerHostName(address.toString()); proxy = QNetworkProxyFactory::proxyForQuery(query).constFirst(); }