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

MQTT Client-ID not accepted by all brokers #440

Open
Dada40 opened this issue May 9, 2021 · 1 comment
Open

MQTT Client-ID not accepted by all brokers #440

Dada40 opened this issue May 9, 2021 · 1 comment
Labels

Comments

@Dada40
Copy link

Dada40 commented May 9, 2021

The MQTT Client-ID that is generated by homebridge-mqttthing is not supported by all MQTT broker.

MQTT specification states:

The Server MUST allow ClientID’s which are between 1 and 23 UTF-8 encoded bytes in length, and that contain only the characters "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" [MQTT-3.1.3-5].

The Server MAY allow ClientID’s that contain more than 23 encoded bytes. The Server MAY allow ClientID’s that contain characters not included in the list given above.

As homebridge-mqttthing includes underscores and more than 23 characters in its client-ID, it might be rejected by some servers:

[09/05/2021, 08:34:04] [ThermostatMQTT] MQTT options: {"keepalive":10,"clientId":"mqttthing_ThermostatMQTT_30c56e2b","protocolId":"MQTT","protocolVersion":4,"clean":true,"reconnectPeriod":1000,"connectTimeout":30000,"will":{"topic":"WillMsg","payload":"mqtt-thing [ThermostatMQTT] has stopped","qos":0,"retain":false},"rejectUnauthorized":false}

[09/05/2021, 08:34:04] [ThermostatMQTT] MQTT Error: Error: Connection refused: Identifier rejected

Workaround:
Client-ID can be overriden manually by defining mqttOptions in the accessory:

"mqttOptions": {
    "clientId": "mqttthingThermostatMQTT"
}

Fix:
It would be nice (enhancement) if homebridge-mqttthing matches to the minimum requirements of the client-ID as defined in MQTT specification. That would increase out-of-the-box compatibility with more MQTT brokers, without applying any workarounds.

@arachnetech arachnetech added the bug label May 9, 2021
@arachnetech
Copy link
Owner

Good spot, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants