0

We would like to understand the behaviour of verneMQ when There is no clientID in Connect request and client provides only registered username,password, keepalive session as 0, connect timeout as 60 X 60 X 1000

How the session is managed by the VerneMQ in this scenario. If VerneMQ is restarted when such cleint is connected, after restart at the client side we observed that subscribed topics of the client are loss.Why is this behaviour?

ONRao
  • 11
  • 1

1 Answers1

1

Omitting the ClientId when connecting will make the broker generate a unique id for this client (if permitted). From the MQTT specification:

A Server MAY allow a Client to supply a ClientId that has a length of zero bytes, however if it does so the Server MUST treat this as a special case and assign a unique ClientId to that Client. It MUST then process the CONNECT packet as if the Client had provided that unique ClientId (Oasis MQTT)

Using an empty ClientId comes along with the condition that it has to be a CleanSession - otherwise the connection will be refused:

If the Client supplies a zero-byte ClientId, the Client MUST also set CleanSession to 1

(because the ClientId is essential for the broker to persist and resume on a session)

Since the broker stores the client's subscriptions (among other things) within the session, you always have to re-subscribe all topics when using an empty ClientId and thereby with CleanSession=1

Odysseus
  • 1,213
  • 4
  • 12
  • Thank you Odysseus for quicker response. Yes we understood that from teh MQTT Specification here in this post what was the VerneMQ implementation behaviour as it i sa non-normative requirement. – ONRao Aug 19 '20 at 07:31
  • @ONRao Regarding your description, the VerneMQ broker seems to follow the MQTT specification: Because you omit the `ClientId` it has to be a `CleanSession`. So when you reconnect everything of the previous session (like the subscriptions) is discarded. Maybe you have to clarify what's still unclear. – Odysseus Aug 19 '20 at 08:15