Search code examples
arduinorabbitmqmqtt

arduino - obtain data from rabbitmq


Im not a English so sorry for my language at first.

!Problem resolved: look to comments section!

Current state: I developed small android app to send data for my own rabbitmq server. Next, I installed mqtt plugin.

Problem: how to connect rabbitmq with arduino ? I tried to connect by given piece of code, without results

void connectMQTT() {
  Serial.print("Attempting to MQTT broker: ");
  Serial.print("127.0.0.1);
  mqttClient.setUsernamePassword(MQTT_USER, MQTT_PASSWD);

  while (!mqttClient.connect("127.0.0.1", 1883)) {
    delay(5000);
  }

  Serial.println("You're connected to the MQTT broker");
  mqttClient.subscribe("NanoIot33_1/sub");
}

Bellow is config for mqttClient

  #include <WiFiNINA.h>
  #include <ArduinoMqttClient.h>

  WiFiClient    wifiClient;
  MqttClient    mqttClient(wifiClient);

Any idea what's wrong ?


Solution

  • My mqtt server is running on virtualbox. I opened a good port from virtualbox, but to 127.0.0.1 instead of ip from ipconfig.