Open sylr opened 1 year ago
It happens to me as well. Also I'm not sure that re-subscribing too fast is the only factor, since my code retries for 5 seconds. Has anyone else encountered this issue?
Hello @sylr, @hofit-cylus. Sorry it took so long - I am looking at the issue now and will let you know when I have a solution.
Did you have any luck finding a solution?
The issue stems from the fact that the server asynchronously tracks bound interest, so at the moment of asking for consumer info in Subscribe()
it may not yet be updated - so after unsubscribing and re-subscribing, there is a possibility of race which the client can do little about. Changing this behavior on the server would make checking for consumer info heavier (and it is already a resource-heave operation)
As a workaround it is possible to use the nats.SkipConsumerLookup()
option in subscribe which makes the client skip explicitly calling consumer info to verify whether the consumer name in Bind()
exists.
Hello,
I've a JetStream subscription bound to a consumer and on a periodic basis I unsubscribe, do a few things and re-subscribe.
Sometimes the re-subscribe fails with
consumer is already bound to a subscription
. I suspect that re-subscribing too fast might be a factor in this.Here a reproduction: