Skip to content

fix: clean up dead client connections on SocketException in NioReceiver#113

Open
technosophy wants to merge 1 commit intoDempsy:masterfrom
KognitionAI:qa/nio-receiver-connection-reset-cleanup
Open

fix: clean up dead client connections on SocketException in NioReceiver#113
technosophy wants to merge 1 commit intoDempsy:masterfrom
KognitionAI:qa/nio-receiver-connection-reset-cleanup

Conversation

@technosophy
Copy link
Contributor

When a client connection resets (Connection reset SocketException), the IOException was caught by the outer reader loop but the broken channel and selector key were never cleaned up. Over time, dead keys accumulate in the selector, firing readable events every cycle, causing a busy spin that starves the reader thread and effectively stops the service from processing new messages.

Fix: catch IOException at the individual Client.read() call site and invoke closeup() to properly cancel the key and close the channel, matching the cleanup behavior already used for EOF and corrupt messages.

…er reader loop

When a client connection resets (Connection reset SocketException), the
IOException was caught by the outer reader loop but the broken channel
and selector key were never cleaned up. Over time, dead keys accumulate
in the selector, firing readable events every cycle, causing a busy spin
that starves the reader thread and effectively stops the service from
processing new messages.

Fix: catch IOException at the individual Client.read() call site and
invoke closeup() to properly cancel the key and close the channel,
matching the cleanup behavior already used for EOF and corrupt messages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant