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

QWebsocket doesn't receive text (binary) message with size > 32 kb

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.12.1
    • Fix Version/s: 5.14.0 Alpha
    • Component/s: WebSockets
    • Labels:
      None
    • Environment:
      Win10, Qt 5.12.1
    • Platform/s:
      Windows
    • Commits:
      b14f5f59a3ae96949e6a33302385a751d6448182 (qt/qtwebsockets/dev)

      Description

      Code example:

      //==================================
      #include <QCoreApplication>
      #include <QWebSocketServer>
      #include <QWebSocket>
      
      int main(int argc, char *argv[])
      {
       QCoreApplication a(argc, argv);
      
      QWebSocketServer wss("ptnpnx", QWebSocketServer::NonSecureMode);
      
      if (!wss.listen(QHostAddress::Any, 2525)) {
       qDebug() << "Failed to start websocket server";
       return EXIT_FAILURE;
       }
      
      QObject::connect(&wss, &QWebSocketServer::newConnection
       , [&](){
       QWebSocket *pSocket = wss.nextPendingConnection();
       qDebug() << "Service side socket is defined";
      
      std::string msg(static_cast<long long>(std::pow(2,15)), 'a');
       QString sendString = QString::fromStdString(msg);
      
      qDebug() << "Server about to send message";
       pSocket->sendTextMessage(sendString.toUtf8());
       qDebug() << "Server send message. Length" << sendString.length();
      
      }
       );
      
      
       QWebSocket ws;
       ws.open(QUrl("ws://localhost:2525"));
      
      QObject::connect(&ws, &QWebSocket::textMessageReceived
       , [&](const QString &message){
       qDebug() << "Client side received a text message. Lenght is" << message.length();
       }
       );
      
      // QObject::connect(&ws, &QWebSocket::binaryMessageReceived
      // , [&](const QString &message){
      // qDebug() << "Client side received a binary message. Lenght is" << message.length();
      // }
      // );
      
      return a.exec();
      }
      
      
      //===================================
      
      

      If change size on 14 (in std::pow(2,15)) - all works fine.

       

        Attachments

        1. WSClientServer.zip
          3 kB
        2. WSServer.zip
          2 kB
        3. WSServer.zip
          2 kB
        4. WSServerTest.zip
          3 kB
        For Gerrit Dashboard: QTBUG-74464
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            ryan_chu Ryan Chu
            Reporter:
            kirilleremeev Kirill Eremeev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes