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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.14.0 Alpha
    • 5.12.1
    • WebSockets
    • None
    • Win10, Qt 5.12.1
    • Windows
    • 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. WSServerTest.zip
          3 kB
        2. WSClientServer.zip
          3 kB
        3. WSServer.zip
          2 kB
        4. WSServer.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ryan_chu Ryan Chu
            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