I have a C++ Qt application that uses QWebSocket which connects to a server that uses uWS. When the server closes the websocket and specifies a close code and close reason, QWebSocket::closeCode() returns 1002 and closeReason(): "Invalid close code 1002 detected." This is even when I have the server send a close code that is not 1002 and a customized message for close reason. It has worked correctly in some cases, but I'm still trying to find out what makes it misbehave. I first thought that it was because the server was not sending a valid close code, because initially I was using 404, which is invalid, but then I changed it to test the close code values in QWebSocketProtocol::CloseCode, but the issue persists. Is there a specific reason why QWebSocket::closeCode() would return 1002 even though the server is sending a valid close code? Any help would be appreciated.

The application uses Qt 5.12.3 with mingw 7.3.0 32-bit on Windows.