Config clientID in MQTT broker

chongz
Comes here often

Config clientID in MQTT broker

Hi,

 

Is there a place to configure the clientID in the MQTT since my broker only support V3?

 

It's the -i option in mosquitto_pub CLI https://mosquitto.org/man/mosquitto_pub-1.html :

 

-i,
--id

The id to use for this client. If not given, a client id will be generated depending on the MQTT version being used. For v3.1.1/v3.1, the client generates a client id in the format mosq-XXXXXXXXXXXXXXXXXX, where the X are replaced with random alphanumeric characters. For v5.0, the client sends a zero length client id, and the server will generate a client id for the client.

 

 

Thanks,

cz

4 Replies 4
a5it
Getting noticed

Hello Chongz,
 
Yes, you can configure the clientID in MQTT when using a client library, as most libraries support setting a custom clientID. Here's how you can do it with some popular MQTT libraries:
 
1. Eclipse Paho (Python):
python
import paho.mqtt.client as mqtt

client = mqtt.Client(client_id="your_custom_clientID")
2. Eclipse Paho (Java):
java
import org.eclipse.paho.client.mqttv3.MqttClient;

MqttClient client = new MqttClient("tcp://broker.example.com:1883", "your_custom_clientID");
3. Mosquitto (C):
c
#include <mosquitto.h>

struct mosquitto *mosq = mosquitto_new("your_custom_clientID", true, NULL);
In each of these examples, replace "your_custom_clientID" with the desired clientID for your MQTT client. This will then set the provided clientID for the MQTT connection.Keep in mind that when using the mosquitto_pub CLI command, you can set the clientID using the -i option as you've mentioned:
mosquitto_pub -h broker.example.com -t "your/topic" -m "message" -i "your_custom_clientID"
Again, replace "your_custom_clientID" with the desired clientID.This response is powered by A5 IT AI.
 
Credit: a5it.com

 

chongz
Comes here often

Thanks.

 

Sorry I wasn't clear. I was asking if client id can be configured in the Meraki dashboard under "IoT Radio Settings" -> "MQTT broker" > "MQTT telemetry streaming"

Screen Shot 2023-05-19 at 8.03.14 AM.png

 

alemabrahao
Kind of a big deal
Kind of a big deal

As far as I know, it's not possible to configure. Maybe you should open a support case.

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.

ok thank!

Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.
Labels