Closed 3gcodes closed 3 years ago
You are getting a connect ack back with a reason code of 'identifier rejected'.
Looking at the logs you are not setting a client identifier -
I/flutter ( 9784): MqttConnectPayload - client identifier is :
This will affect some brokers, which broker are you using?
You don't say what number the closed issue is however this seems to not be an error with the client.
Thanks for the info. However, I am setting the client id.
MqttServerClient client = MqttServerClient.withPort('192.168.0.34', 'client-1', 1883);
I even tried
client.clientIdentifier = "client-1";
I have tried hivemq and emqx, but giving the same results. I can connect to both using MQTT X. The old issue number is https://github.com/ThomDietrich/miflora-mqtt-daemon/issues/55.
Okay, I figured it out. I had to add .withClientIdentifier("client-1")
to my MqttConnectionMessage. But I'm unsure why, if I've set it on the client itself.
Yep, if you supply your own connect message the client identifier you specify in the constructor isn't used, you are expected to supply this yourself as you have discovered. I think this is misleading, its not obvious you need to do this, I'll put a fix in so people don't get caught by this again.
Terrific! Thanks.
Complete, package re published at version 9.1.0.
I know there's a similar issue from 2018 that is closed, but I'm getting the same error. I'm using this as my example code...
https://medium.com/@emqtt/using-mqtt-in-the-flutter-project-6a5d90179c8b
Flutter version info:
And getting the following: