MQTT connect failed, error -1

I am using;

  • Arduino Mega 1280 with ESP8266
  • Web dashboard

I am trying to open/close a relay that is connected to my Arduino. But even if I could manage to connect, I can not perform any action.

On the web dashboard it simply shows me spinning dots, and then says the device is offline…

Here is my code btw;

#define CAYENNE_DEBUG       // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space

#define VIRTUAL_CHANNEL 2
#define ACTUATOR_PIN 4

#include <CayenneMQTTESP8266Shield.h>
#include <ESP8266SerialLibrary.h>

// WiFi network info.
char ssid[] = "ssid";
char wifiPassword[] = "password";

// Cayenne authentication info.
char username[] = "username";
char password[] = "password";
char clientID[] = "client_id";

// ESP8266 Serial object.
#define EspSerial Serial1

ESP8266 wifi(&EspSerial);

void setup()
{
  Serial.begin(9600);
  delay(10);

  pinMode(ACTUATOR_PIN, OUTPUT);

  // Set ESP8266 baud rate
  EspSerial.begin(115200);
  //EspSerial.begin(115200);
  delay(50);

  Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);
}

void loop()
{
  Cayenne.loop();
}

// Data from Cayenne.
CAYENNE_IN(VIRTUAL_CHANNEL)
{
  // Write value to turn the relay switch on or off. This code assumes you wire your relay as normally open.
  if (getValue.asInt() == 0)
  {
    digitalWrite(ACTUATOR_PIN, HIGH);
  }
  else
  {
    digitalWrite(ACTUATOR_PIN, LOW);
  }
}

// Send data to Cayenne
CAYENNE_OUT_DEFAULT()
{
  // Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
  // Cayenne.virtualWrite(0, millis());
  // Some examples of other functions you can use to send data.
  //Cayenne.celsiusWrite(1, 22.0);
  //Cayenne.luxWrite(2, 700);
  //Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}

I am writing ssid and password of the WiFi, and username, clientID, password to the corresponding places of course.

New development:

After 5-6 “MQTT connect failed, error -1” messages it said “Connected”.

But my web dashboard says offline.

It said “Disconnected” again and started giving the same error message again…

There is currently a problem that is being worked on.

It was fixed yesterday but having the same issue today again… What is the latest status?