Skip to content
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

how to stop receive event_callback #1007

Open
bmiyuan opened this issue Jun 27, 2023 · 3 comments
Open

how to stop receive event_callback #1007

bmiyuan opened this issue Jun 27, 2023 · 3 comments

Comments

@bmiyuan
Copy link

bmiyuan commented Jun 27, 2023

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

@Jarema
Copy link
Member

Jarema commented Jul 8, 2023

Hey,

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

@caspervonb
Copy link
Collaborator

caspervonb commented Jul 12, 2023

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

@barafael
Copy link
Contributor

@bmiyuan can this issue be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants