Hmmm.. I understand the rationales and argument but I remain to be convinced.
Of course, brokers are very capable of generating good ids, as they (a) are written by very capable people in the main and (b) have full knowledge of the topic space and clients, etc. But it's of very little use, as the client doesn't know it unless we change the protocol... I also have concerns about re-interpreting 'empty' as a special sentinel value.
I think some of the impact of this behaviour is mitigated in situations where:-
- A client has to use credentials to authenticate, and so a broker implementation can have a manual delete (obviously not completely ideal)
- Client libraries that do generate random ids do so before connection, and pass them via the API to the connecting code to manage.
- I do like Roger's original suggestion on the MQTT wiki.
Having long-lived client ids is extremely powerful (eg tracking, logging, audit, etc), even if it is awkward for clients (eg "What is unique?" "What should I use?" "Where do I store it?") With our extended identifier size, clients are free to use MAC addresses, one-off GUIDs, hostnames, ipV6 addresses (which when link-local and without privacy extensions are effectively MACs), hostname + processname + process instance, etc. It also maps very nicely to AMQP 1-0's container-id (or link-name) concepts for implementers that might want to bridge protocols.
There are also places where a client should know its own id, anyway, even if random and for dynamic purposes, eg dynamic topics with reply-to, etc.
So, in summary, I'd support adding a non-normative comment to the spec along the lines Roger proposes.
I'd been thinking about this problem/situation and how instead it might solved on the server side. For example a client connecting with clean session false and a 0 length clientId would be saying; "I don't care about my state I just want to connect and send/receive data", in this case the server can handle either assigning it internally a guaranteed unique clientId or managing it in some other way, but the client implementation doesn't need to know/care about the details or attempt to generate a clientId it hopes will be unique.
This is probably a change beyond the scope of the charter, but as it's related to the above I figure it's worth mentioning here.