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.
Hi, I recently have encountered some problem with handling closed socket.
I had a lot of processes in my application and some of them have very often received 'eof' from socket (why this happend I'm not sure yet, probably it's something with system resources/connection speed/NATS server termination).
In most cases I have just received
Server xyz closed the connection
, but sometimes I got for example:Invalid protocol MS
or something likeUnexpected error: Expected integer, but got "" while executing "incr expMsgLength 2"
.Both this messages looked like we got only part of message while reading from socket. I have read about
chan gets channelId ?varName?
in the documentation and it says:So we actually can read part of message, if there was
eof
later, and treat it as a whole causing problem with handling it further. If we moveeof
check above thatif
statement, we will terminate it quicker and do re-connect without unexpected errors.I have encountered this in old version, but I see that it is probably still here :)
Best regards