UUID as client ID
Closed this issue · 2 comments
I understand that MQTT 3.1.1 allows client IDs longer than 23, but this library still restricts them to 23. Any objections to removing this restriction?
Hi @marclennox,
If you enable version 3.1.1 mode in the client (client.version = '3.1.1'), then there is no restriction on the Client ID length. See: https://github.com/njh/ruby-mqtt/blob/master/lib/mqtt/packet.rb#L483
However version 3.1.1 specifies "The Server MAY allow ClientId’s that contain more than 23 encoded bytes." - so it is possible that there are MQTT servers that don't.
In terms of the library generating a client id automatically, version 3.1.1 of the protocol specifies that a server may allow an empty client id:
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.
Which is much better than the client randomly making one up.
Let me know if I am missing something or you have discovered a bug.
nick.
Thanks @njh, this worked for me!