unsubscribe_after
forgotten on reconnection
#1302
Labels
defect
Suspected defect such as a bug or regression
unsubscribe_after
forgotten on reconnection
#1302
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: