Q- Do all clients need a unique client name?

A- Yes .The client name is used by the MQTT broker to identify the client.

This is necessary when using persistent connections (clean session flag False), as the broker needs to store messages for the client when the client isn’t connected.

Q- What are clean sessions?

A- When a client connects to a broker it can set a clean session flag to indicate to the broker that is doesn’t need to retain any session information for this client after it has disconnected. In the clean session flag is set to False then the broker will remember the topics that the client subscribed to and also will store messages sent to that topics for the the client so that when the client re-connects it will receive those messages. This is however dependent on QOS settings. See MQTT Clean Sessions and QOS Examples

Q- What happens to messages that get published to topics that no one subscribes to?

A- They are discarded by the broker.

Q-How can I find out what topics have been published?

A- You can’t do this easily as the broker doesn’t seem to keep a list of published topics as they aren’t permanent.

Q- Can I subscribe to a topic that no one is publishing to?

A- Yes

Q- Can I publish and subscribe using the same client connection?

A- Yes

Q- Are messages stored on the broker?

A- Yes but only temporarily. Once they have been sent to all subscribers they are then discarded. But see next question.

Q- What are retained messages?

A- When you publish a message you can have the broker store the last  published message. This message will be the first message that new subscribers see when they subscribe to that topic.  MQTT only retains 1 message. See Retained Messages by example

Q- What is a last will message?

A– It is a message sent by a broker when an MQTT client gets disconnected abnormally- See Last Will and Testament by example

Q- What is MQTT-SN?

MQTT-SN stands for MQTT for sensor networks. It uses UDP instead of TCP and isdesigned to work over UDP, ZigBee and other transports. See MQTT-SN working Notes.

Mosquitto Broker

Q- How do I delete, clear or remove all retained messages on the Mosquitto broker.

A- If you’re not using the persistent database then  easiest way is to stop and restart mosquitto. Otherwise you will need to subscribe to all topics to check and clear the retained messages. You can use my Python script to do this. However this is not recommended on a busy broker.

Q-How do I delete a topic or topic hierarchy?

A- You can’t delete a topic from the broker. Topics are created by the clients. Topics are automatically remove from a broker when no client is subscribed to them or the broker isn’t holding a topic open for a client that has a persistent connection. See Understanding topics and MQTT clean sessions.

Please rate? And use Comments to let me know more