Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.8.3
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
Gerrit Reviews
For Gerrit Dashboard: QTBUG-136216 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
641274,7 | QWebSocketDataProcessor: Restore utf-8 decoding state | dev | qt/qtwebsockets | Status: NEW | +1 | 0 |