-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Is there a way to get event of a client getting disconnected from NATS server. #586
Comments
See the disconnect handler in the Go client (and equivalent in other clients). https://godoc.org/github.com/nats-io/go-nats#Conn.SetDisconnectHandler |
I believe you are speaking of the last will and testament functionality in MQTT. We do not have that today; by nature the NATS server maintains very little state about its clients. Could you describe your use case? There may be another solution. |
@tylertreat @ColinSullivan1 thanks for your quick reply. @ColinSullivan1 |
@ritesh4302 , Thank you for sharing; I appreciate that. We don't have a realtime event notification for connection related events, although this has come up in the past. You are using the recommended approach with the features NATS provides today. Let's leave this open to track this idea. |
There is always a struggle between functionality at the system and application level to those desired in the product itself. NATS started with the thought that only the bare minimum needed to exist in NATS itself, and that applications and systems are able to easily implement the functionality they desire. This feels like one of those cases. Happy to help brainstorm a solution for you. |
@derekcollison , @ColinSullivan1 |
Do you need any guarantees around the event that a client has been disconnected? One option to entertain would be to look at taking what you've already done - polling the monitoring endpoints looking for differences - and then using that information to publish messages on specific event subjects. This would be a separate process outside of the NATS server(s), and could simplify other application code you might have. If you wish to fork and implement this yourself, you'll probably find it is more involved than it looks up front. There is an old branch with functionality along these lines here, and the place to start looking would be here. |
Do we get any event if any client gets disconneted from the broker, like in Mqtt we get to set a payload message for each client during client creation, and if the client is offline for a certain amount of time, then the server broadcast this payload message to all the connected clients.
Thanks in advance.
The text was updated successfully, but these errors were encountered: