ArduinoMqttClient icon indicating copy to clipboard operation
ArduinoMqttClient copied to clipboard

MQTT version support

Open jiferrero opened this issue 6 years ago • 2 comments

Hi,

Which MQTT version does the library currently support? We are struggling our heads to know why our arduino nano 33 iot always get a connection refused when connecting to EMQX 4.x broker but not when connecting to mosquito.

const char broker[] = "test.mosquitto.org";
int port = 1883;
WiFiClient wifiClient;
MqttClient mqttClient(wifiClient);

void setup() {
  Serial.begin(1000000);
  while (!Serial);

  while (WiFi.begin(ssid, pass) != WL_CONNECTED) {
    // failed, retry
    Serial.print(".");
    delay(5000);
  }

  Serial.println("Device connected to the network");
 
 if (!mqttClient.connect(broker, port)) {
    Serial.print("MQTT connection failed! Error code = ");
    Serial.println(mqttClient.connectError());
    while (1);
  }

  Serial.println("You're connected to the MQTT broker");
}

that ends up with a succesfully connection to "test.mosquitto.org".

But if we use for example: IPAddress broker(192, 168, 1, 33);

then we always ends up with an unsuccessfully connection. We have no idea why... port 1883 is open and accessible from local network but EMQX 4.x broker supports MQTT 3.1.1 and 5.0 Could be that the problem? Any other idea?

Thank you so much in advance

jiferrero avatar Feb 07 '20 13:02 jiferrero

Hi @jiferrero i make some test with a nano 33 iot and with a wifi1010, it works fine in both case, i have used the following library and core version:

nina-fw: 1.3.0 WiFiNINA: 1.5.0 ArduinoMqttClient: 0.1.3 samd-core: 1.8.5

and of course EMQX 4.x broker the v. 4.0.3 listening on port: 1883, mosquitto completely disabled because listen on the same port

Rocketct avatar Mar 06 '20 08:03 Rocketct

Hi, I also have my Arduino working well with EMQX and this library. But I came here as I was also looking for which version the MQTT protocol is used by this library. @Rocketct do you have the answer ?

jjauzion avatar May 26 '21 15:05 jjauzion

For anyone else is coming here looking for an answer to this question, the answer is version MQTT version 3.1.1. How do I know? The library has set level 0x04, which according to the MQTT spec is the identifier for 3.1.1

chocolatkey avatar Dec 31 '23 04:12 chocolatkey

@chocolatkey is correct 😉

aentinger avatar Jan 08 '24 05:01 aentinger