I get close reason: ‘Invalid UTF-8 code encountered.’ (code=1007) with QWebSocket
in the following scenario:
- I connect to
Binance
stream wss://stream.binance.com:9443/stream
with QWebSocket::open
. - Successfully receive messages for some time period (a few hours).
Binance
disconnects me when its servers load increases (because I have low-priority API) and I get close reason code=1000 that indicates a normal closure.- Try to reconnect multiple times by calling
QWebSocket::open
again, but Binance
closes the connection with close reason ‘Invalid UTF-8 code encountered.’ (code=1007) that indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message). - Restart the application manually and connect successfully.
The difficulty of reproducing the bug is that Binance
disconnects me rarely (once a day, for example) and experimentation with disconnecting the network cable from my machine does not have this effect, after I connect the cable back, QWebSocker
reconnects successfully. When I disconnect the network cable I get Error: ‘Unknown error’ (code=-1), Close reason: ” (code=1000).
(more…)