Open bruth opened 7 months ago
've been combing through the documentation, trying to find something similar to what you're describing. I'm working on implementing a presence system to track who's online or offline and notify clients when someone disconnects due to a socket close or termination, but I haven't quite found the solution I'm looking for.
As a workaround, I'm building small microservices that handle this logic using NATS and Dragonfly. The idea is to implement a heartbeat system that listens to JetStream, ensuring that at least one message reaches my backend. I'll store the user info in the cache, and if a user doesn't send another heartbeat within a specified number of seconds, it will notify all listeners on the stream that this user has disconnected. I'll handle the rest with my custom SDK wrapper. Also, Dragonfly is an incredibly fast caching database that runs with the Redis SDK.
If there's any other workaround, that would be great. I'm planning to use NATS.go, not the server version, and will listen to a specific reserved channel/stream configured by the run command.
The system generates events for any connect and disconnect event.
$SYS.ACCOUNT.*.CONNECT
$SYS.ACCOUNT.*.DISCONNECT
The third token will be the account name or public key if in operator mode.
Proposed change
Add client connect metadata (key-value pairs) that can be reported back in monitoring data.
Use case
Currently there is the
name
anddescription
option to differentiate clients.name
can be used to uniquely identify, but there may be additional facets of metadata per client connection, such as region, factory, cloud, etc. that can be useful when reporting connections.Contribution
No response