Skip to content
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

Closed
johpe opened this issue Oct 17, 2016 · 3 comments
Closed

Client to supply a ClientId that has a length of zero bytes #291

johpe opened this issue Oct 17, 2016 · 3 comments
Labels
Component: libmosquitto Type: Enhancement A new feature for a minor or major release.
Milestone

Comments

@johpe
Copy link

johpe commented Oct 17, 2016

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.

@ralight
Copy link
Contributor

ralight commented Oct 17, 2016

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.

@johpe
Copy link
Author

johpe commented Oct 17, 2016

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?

@PierreF PierreF added Type: Enhancement A new feature for a minor or major release. Component: libmosquitto labels Jan 5, 2018
@ralight ralight added this to the 1.6 milestone Sep 27, 2018
ralight added a commit that referenced this issue Sep 4, 2019
These are now expected to be generated on the broker. This matches the
behaviour for v5 clients.

Closes #291.
@ralight ralight modified the milestones: 1.6, 1.7 Sep 4, 2019
@ralight
Copy link
Contributor

ralight commented Sep 4, 2019

This didn't get done for 1.6 (except for v5 clients), so I've bumped it to 1.7 and made the change.

@ralight ralight closed this as completed Sep 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 3, 2019
@ralight ralight modified the milestones: 1.7, 2.0 Oct 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: libmosquitto Type: Enhancement A new feature for a minor or major release.
Projects
None yet
Development

No branches or pull requests

3 participants