Skip to content

No Close event when server TCP socket closed #469

@mduint32

Description

@mduint32

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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions