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 configuration #1033

Closed
VonOx opened this issue Jan 2, 2021 · 3 comments · Fixed by #1034
Closed

[MQTT] Client ID configuration #1033

VonOx opened this issue Jan 2, 2021 · 3 comments · Fixed by #1034
Labels
effort:low Tasks lower than 2 hours to develop enhancement

Comments

@VonOx
Copy link
Contributor

VonOx commented Jan 2, 2021

I think we need to be able to change the client id in MQTT configuration.

Use case:
Single MQTT server with 2 Gladys containers ( Prod / Preprod )

Problem:
For now only one instance can be connected to mosquitto ( Connection is closed if same client id is used )

Logs:

1609587948: New connection from 192.168.1.42 on port 1883.
1609587948: Client gladys-assistant-main-instance already connected, closing old connection.
1609587948: New client connected from 192.168.1.42 as gladys-assistant-main-instance (p2, c1, k60, u'gladysmain').
1609587953: New connection from 192.168.1.42 on port 1883.
1609587953: Client gladys-assistant-main-instance already connected, closing old connection.
1609587953: New client connected from 192.168.1.42 as gladys-assistant-main-instance (p2, c1, k60, u'gladysdev').
1609587958: New connection from 192.168.1.42 on port 1883.
@VonOx VonOx changed the title MQTT Client ID configuration [MQTT] Client ID configuration Jan 2, 2021
@VonOx VonOx added the effort:low Tasks lower than 2 hours to develop label Jan 2, 2021
@Pierre-Gilles
Copy link
Contributor

We could generate an ID to append at the end of the client_id to avoid that :)

@VonOx
Copy link
Contributor Author

VonOx commented Jan 6, 2021

Client ID lenght must be limited in lenght ( MQTT Spec say 23 but majority of mqtt servers can handle more)
So I've used Math.random because uuid is too long

New client connected from 192.168.1.23 as gladys-main-instance-155267 (p2, c1, k60, u'gladysmain').

clientId: 'gladys-main-instance-'+ Math.floor(Math.random() * 1000000)

Do you agree ?

@Pierre-Gilles
Copy link
Contributor

That's perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort:low Tasks lower than 2 hours to develop enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants