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

QWebSocket "Invalid UTF-8 Code Encountered" Error in Qt6

    XMLWordPrintable

Details

    • All
    • bf8064f88 (dev), 632d10290 (6.9), 387eea57e (tqtc/lts-6.8), 1a914f1db (tqtc/lts-6.5)

    Description

      Description: In a scenario where two Qt programs communicate via QWebSocket, the receiving side occasionally closes the socket with the error "Invalid UTF-8 code encountered." The sending program always uses the following code to transmit UTF-8 encoded JSON documents:
      QJsonDocument doc(aQJsonObject);
      client->sendTextMessage(doc.toJson());

      This issue occurs after migrating from Qt5 to Qt6, where QTextCodec was replaced by QStringDecoder, which defaults to QStringDecoder::Flag::Stateless. It has been observed that removing the Stateless flag resolves the issue, suggesting that stateless decoding may be the cause.

      Environment:

      • OS: OpenSUSE Tumbleweed
      • Compiler: GCC 14.2
      • Qt Version: Qt6

      Suspected Cause: The change in decoding behavior between Qt5 and Qt6 (from QTextCodec to QStringDecoder with the Stateless flag) may be the cause of the error.

       

      Attachments

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

        Activity

          People

            manordheim Mårten Nordheim
            chakib Chakib Boutaghane
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes