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

Non-fatal error received during ssl websocket connection over HTTP proxy

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.10.0, 5.9.4, 5.10.1
    • WebSockets
    • None

    Description

        I've found that in case of ssl websocket connection being proxied there is error reporting by qtcode. Below is example of small program to test:

      #include <QtWebSockets/QWebSocket>
      #include <QObject>
      #include <QCoreApplication>
      
      class tst_QWebSocket : public QObject
      {
          Q_OBJECT
      
      public:
          tst_QWebSocket();
          ~tst_QWebSocket() {;}
      
      public slots:
          void onConnected();
          void onReceivedText(const QString &aMessage);
          void onDisconnected();
          void onWsConnectionError(QAbstractSocket::SocketError aError);
          void onWsSslErrors(const QList<QSslError> &aErrors);
      
      private:
          QWebSocket mWebSocket;
      };
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          tst_QWebSocket tstSocket;
      
          return a.exec();
      }
      
      tst_QWebSocket::tst_QWebSocket():
          QObject()
      {
          mWebSocket.open(QUrl(QStringLiteral("wss://echo.websocket.org")));
          connect(&mWebSocket, SIGNAL(connected()), this, SLOT(onConnected()));
          connect(&mWebSocket, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
          connect(&mWebSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(onReceivedText(QString)));
          connect(&mWebSocket, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(onWsSslErrors(const QList<QSslError> &)));
      }
      
      void tst_QWebSocket::onConnected()
      {
          qDebug() << "Connected";
      
          mWebSocket.sendTextMessage("TestHello!");
      }
      
      void tst_QWebSocket::onReceivedText(const QString &aMessage)
      {
          qDebug() << "Got echo: " << aMessage;
      
          mWebSocket.close();
      }
      
      void tst_QWebSocket::onDisconnected()
      {
          qDebug() << "Disconnected";
      
          qApp->quit();
      }
      
      void tst_QWebSocket::onWsConnectionError(QAbstractSocket::SocketError aError)
      {
          Q_UNUSED(aError);
      
          qDebug() << "Websocket connection error: " << mWebSocket.errorString();
      }
      
      void tst_QWebSocket::onWsSslErrors(const QList<QSslError> &aErrors)
      {
          foreach (const QSslError &error, aErrors)
          {
              qDebug() << "Websocket SSL handshake error: " << error.errorString();
          }
      }
      
      #include "main.moc"
      

      Execution of this program produce:

      $ http_proxy=http://192.168.85.153:3128 ./WebSocketProxyTest
      Connected
      Got echo:  "TestHello!"
      QIODevice::write (QTcpSocket): device not open
      Disconnected
      

      This not a urgent problem but still needs to be fixed.

      Attachments

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

        Activity

          People

            kurt.pattyn Kurt Pattyn
            shuras109 Aleksandr Sbitnev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes