nats.rs
nats.rs copied to clipboard
how to stop receive event_callback
I just create a nats client , the client can subscribe events and works fine, if I stop the nats.exe running, and also drop this nats client, why I still can receive this callback of event Event::ClientError which I register with .event_callback(). is there any way I can stop this callback? such as client.close() or anything else can stop receive this callback?
the create client params as below:
...... let options = ConnectOptions::default() .retry_on_initial_connect() .event_callback(callback); let client = options.connect(ip).await.unwrap(); ......
Hey,
I assume you have a leftover clone of the client somewhere.
We considering adding close()
to make it easier.
As @Jarema eluded to, the callback is shared across all clones of Client
.
Once all clients are dropped the dispatching task will exit.
@bmiyuan can this issue be closed?