title: Attempting MQTT connection...failed, rc=-4 try again in 5 seconds
body: <p>I used aREST to access to my NODEMCU but it says "Attempting MQTT connection...failed, rc=-4 try again in 5 seconds" on serial monitor</p>
  
  <p>My code:</p>
  
  <pre><code>// Control ESP8266 anywhere
  
  // Import required libraries
  #include &lt;ESP8266WiFi.h&gt;
  #include &lt;PubSubClient.h&gt;
  #include &lt;WiFiClientSecure.h&gt;
  #include &lt;aREST.h&gt;
  
  // Clients
  WiFiClient espClient;
  PubSubClient client(espClient);
  
  // Create aREST instance
  aREST rest = aREST(client);
  
  // Unique ID to identify the device for cloud.arest.io
  char* device_id = "aliziveh79";
  
  // WiFi parameters
  const char* ssid = "Samsung J7";
  const char* password = "Movahed12341234";
  
  // Functions
  void callback(char* topic, byte* payload, unsigned int length);
  
  void setup(void)
  {
    // Start Serial
    Serial.begin(115200);
  
    // Set callback
    client.setCallback(callback);
  
    // Give name and ID to device
    rest.set_id(device_id);
    rest.set_name("relay_anywhere");
  
    // Connect to WiFi
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      Serial.print(".");
    }
    Serial.println("");
    Serial.println("WiFi connected");
  
    // Set output topic
    char* out_topic = rest.get_topic();
  
  }
  
  void loop() {
  
    // Connect to the cloud
    rest.loop(client);
  
  }
  
  // Handles message arrived on subscribed topic(s)
  void callback(char* topic, byte* payload, unsigned int length) {
  
    rest.handle_callback(client, topic, payload, length);
  
  }
  </code></pre>
  
  <p>I used aREST to access to my NODEMCU but it says Attempting MQTT connection...failed, rc=-4 try again in 5 seconds" on serial monitor</p>