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

QWebSocket connection error if http_proxy and no_proxy is set

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.12.9
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      Linux/Other display system

      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();
           }
       
      

        Attachments

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

          Activity

            People

            Assignee:
            tpochep Timur Pocheptsov
            Reporter:
            ben.gray Ben Gray
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes