New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client to supply a ClientId that has a length of zero bytes #291
Comments
Just to be clear, the code you quote is client code, not broker code. The mosquitto broker supports this already. libmosquitto does not require you to provide a client id and will generate a random client id for you (rather than letting the broker generate it) if you pass a NULL as the client id. I suppose there is no reason why this couldn't be changed to sending a zero length client id to the broker instead. |
Yes, if we send NULL then libmosquitto will generate a random client id. But we have an implementation where we'd like the server to create the random client id for us when it sees an empty string and according the the MQTT specification that should be OK? |
These are now expected to be generated on the broker. This matches the behaviour for v5 clients. Closes #291.
This didn't get done for 1.6 (except for v5 clients), so I've bumped it to 1.7 and made the change. |
According to 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 [MQTT-3.1.3-6]."
This can be interpreted as that it is not a strict requirement on the client library to allow zero-byte clientIDs.
if(id){ if(STREMPTY(id)){ return MOSQ_ERR_INVAL; } mosq->id = _mosquitto_strdup(id); }else{ mosq->id = (char *)_mosquitto_calloc(24, sizeof(char)); ...
(sorry for the formatting but I just can seem to get line feeds in the code snippet above)
Based on the code above I guess this is not supprted right now, but I think it would be nice if mosquitto could handle this.
The text was updated successfully, but these errors were encountered: