-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unsubscribe_after
forgotten on reconnection
#1302
Comments
Hey! Thanks for detailed description. That way, there is a high chance that both protocol messages will arrive at the server at the same time. To test it - I would actually check if simply calling |
So the |
I would enqueue a fresh UNSUB after immediately afte SUB on reconnect. For testing - I did not find any good way so far. |
Observed behavior
In the following sequence:
unsubscribe_after
nn
messages...in step 3,
async-nats
re-subscribes on the new connection without re-sending anUNSUB {sid} {max}
(where max = prev_max - delivered)....and in step 4,
async-nats
appears to remove the subscription info fromConnectionHandler::subscriptions
here but not actually send anUNSUB
message either....so in step 5, it still continues receiving messages on the sid from the server for this topic, even though they go nowhere. This is a waste in bandwidth that could add up in some use cases.
Expected behavior
In step 3, I think it should send the
UNSUB {sid} {max}
immediately to avoid this.Server and client version
Rust async nats client, current head (053944d)
Host environment
any
Steps to reproduce
I hacked the
force_reconnect
test to observe this:unsub_after
pre-reconnectelse if
branch here to actually see the spurious messagesI'd be happy to put together a fix. The debatable point is how to automatically test the fix is correct. I believe it's normal to get messages on unknown sids for a bit after enqueuing an
UNSUB
because there's a delay before the server actually handles it, and it could have enqueued another message on the topic in the meantime. So this isn't worth causing an error over in general, or likely even enqueueing something onevents_tx
. But we can arrange the sequencing in a test so these messages shouldn't happen if the client is behaving properly. Maybe are there connection stats somewhere we can add a counter to for this, and the test can check those after the fact? I'm open to ideas.The text was updated successfully, but these errors were encountered: