nats.rs icon indicating copy to clipboard operation
nats.rs copied to clipboard

how to stop receive event_callback

Open bmiyuan opened this issue 1 year ago • 3 comments

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(); ......

bmiyuan avatar Jun 27 '23 15:06 bmiyuan

Hey,

I assume you have a leftover clone of the client somewhere. We considering adding close() to make it easier.

Jarema avatar Jul 08 '23 09:07 Jarema

As @Jarema eluded to, the callback is shared across all clones of Client. Once all clients are dropped the dispatching task will exit.

caspervonb avatar Jul 12 '23 11:07 caspervonb

@bmiyuan can this issue be closed?

barafael avatar Dec 25 '23 21:12 barafael