- 
    
Bug
 - 
    Resolution: Fixed
 - 
    
P2: Important
 - 
    6.8.3
 
- 
        
 - 
        bf8064f88 (dev), 632d10290 (6.9), 387eea57e (tqtc/lts-6.8), 1a914f1db (tqtc/lts-6.5)
 
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.