I'm investigating an issue where a linux client application using ix::WebSocket sometimes doesn't react to a websocket server (not IXWebSocket) closing its TCP socket. This is not a graceful websocket close handshake, but on TCP level a RST is being sent (according to WireShark) so the client is actually notified that the connection goes away.
Sometimes this results in the OnMessageCallback being called with a Close message with "abnormal closure" and sometimes it doesn't. When it doesn't, the next time any message is sent (either websocket ping or a regular message) it seems to realize the connection has failed and the OnMessageCallback is called with a Close message with "internal error".
My investigation so far has taken me to WebSocketTransport::poll: if _socket->isReadyToRead returns PollResultType::Error, it calls closeSocket, but the function will still return PollResult::Succeeded.
Won't that mean WebSocket::run will keep retrying poll on a closed socket? Is that intentional?
I experimented with adding return PollResult::AbnormalClose; after closeSocket in that if clause. It improved behavior in my case: I reliably get Close directly and with "abnormal closure".
I'm investigating an issue where a linux client application using
ix::WebSocket
sometimes doesn't react to a websocket server (not IXWebSocket) closing its TCP socket. This is not a graceful websocket close handshake, but on TCP level a RST is being sent (according to WireShark) so the client is actually notified that the connection goes away.Sometimes this results in the OnMessageCallback being called with a Close message with "abnormal closure" and sometimes it doesn't. When it doesn't, the next time any message is sent (either websocket ping or a regular message) it seems to realize the connection has failed and the OnMessageCallback is called with a Close message with "internal error".
My investigation so far has taken me to
WebSocketTransport::poll
: if_socket->isReadyToRead
returns PollResultType::Error, it callscloseSocket
, but the function will still return PollResult::Succeeded.https://github.com/machinezone/IXWebSocket/blob/f79c64ae9741796acf4144ec86336880b644463d/ixwebsocket/IXWebSocketTransport.cpp#L377
Won't that mean
WebSocket::run
will keep retrying poll on a closed socket? Is that intentional?I experimented with adding
return PollResult::AbnormalClose;
after closeSocket in that if clause. It improved behavior in my case: I reliably get Close directly and with "abnormal closure".