0

Is there a way to check if a client has initially connected. I want to send a message to a topic if a client has "logged in".

1 Answer 1

3

There is no client presence detection built into MQTT at the protocol level.

But there is nothing to stop you building it yourself.

Have the client publish a retained message on a known topic e.g. presence/<client-id> and then set up a Last Will and Testament to either clear the message or publish a different value (e.g. online vs offline). You will also need to explicitly clear it if the client shuts down cleanly.

Other clients can subscribe to presense/+ in order to keep track of which clients are online.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.