Unknown Protocol Operation after reconnect when sending message#2
Open
basbl wants to merge 2 commits into
Open
Unknown Protocol Operation after reconnect when sending message#2basbl wants to merge 2 commits into
basbl wants to merge 2 commits into
Conversation
When a message is larger than the connection packet size it is written to the socket with several fwrite() calls. If the socket dies *after* the first chunk has been written, Connection::sendMessage() catches the error, reconnects, and resumes the write loop. The byte offset counter $total must be reset to 0 so the *whole* message is resent on the fresh socket. Before the fix $total kept its stale value, so only the tail of the PUB command was sent on the new connection. The NATS server then saw the tail bytes as a fresh protocol command and answered `-ERR 'Unknown Protocol Operation'`.
MattiasAng
approved these changes
Jun 25, 2026
Member
Author
|
Before merging we need to decide whether we want to keep the notes somewhere in a docs folder. |
Member
I'd say move to docs/changelogs. |
dcc5ea2 to
6c2c155
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.
While investigating a breaching SLO for eConsent caused by Unknown Protocol Operations I ended up here.
The investigation led me to the
Connection::sendMessage-method which after a reconnect does not write the full message to the socket as the running total is not reset.To me this makes sense as it does look like an obvious oversight. Looking for feedback!
Last commit contains the notes on the investigation. We can decide to keep this if we want and give it a place in the repo (docs) or drop it.