Fix connection reset instead of kick message#595
Open
purpurcof wants to merge 1 commit into
Open
Conversation
Contributor
Owner
|
Please include the name and model of the AI you used to make this commit/PR. |
Owner
|
Were you able to reproduce #595 and test that this PR fixes it? |
3ce7a5e to
b0902a2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After successful verification, the player receives "Connection Reset" instead of the proper kick/disconnect message.
Fixes #476
Root Cause
In
VerificationHandler.fail(), after callinguser.disconnect()→closeWith(), aQuietDecoderExceptionis thrown. The exception propagates toTailExceptionsHandler.exceptionCaught(), which callsctx.close()immediately — beforecloseWith()can properly send the packet.AbstractUnsafe.close()setscloseInitiated = trueand nullsoutboundBuffer, making the 50ms scheduled close fromcloseWith()a no-op.NioSocketChannel.doClose()callsjavaChannel().close()right away. If the kernel receive buffer has unread data (a keep-alive from the client), the kernel sends TCP RST, discarding the pending disconnect data in the send buffer. The client sees "Connection Reset".Fix
ProtocolUtil.closeWith() —
setAutoRead(false)+ 50ms close delay:setAutoRead(false)prevents client data from entering the kernel receive bufferclose()is calledSonarPacketDecoder.channelRead() — catch
QuietDecoderException:fail()no longer reachesTailExceptionsHandlercloseInitiatedis not set prematurelycloseWith()closes the channel after the delay as intended, not immediatelyMade with Claude Opus 4.8