Suddenly: could not connect to mqtts-sa.iot.arduino.cc:8883

I've got two MKR WIFI 1010. One of them was connected to the cloud and running, the other one is an ongoing project. When working with the ongoing project, I had a pause, and when I continued again, I've got this error message:

ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-sa.iot.arduino.cc:8883
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 3 connection attempt at tick time 111081

Checking data for the other MKR, I noticed that it had not posted any new values for a while. I fetched it, and the same error occurred.

***** Arduino IoT Cloud - configuration info *****
Device ID: c35cf23c-d54c-42c9-9246-71d774b627b3
Thing ID: 68087245-caa3-4166-b6ec-79606437a2fe
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
hei
WiFi.status(): 0
Current WiFi Firmware: 1.4.7
hei
Connected to "MyWifi"
hei
hei
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-sa.iot.arduino.cc:8883
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 1 connection attempt at tick time 36013

I've read all I can find both here in forum and on google, but nothing seems to fit my situation. I've even deleted the device, and created a new thing for scratch, with a auto generated sketch. It doesn't work.

Here's the sketch

/* 
  Sketch generated by the Arduino IoT Cloud Thing "thg_test"
  https://create.arduino.cc/cloud/things/68087245-caa3-4166-b6ec-79606437a2fe 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudTemperature test;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection,false);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {

    test = 20;
    Serial.println("hei");
    ArduinoCloud.update();
    delay(2000);
}

I've been banging my head for several days now, and I'm stuck. Unable to find any steps for how to troubleshoot this problem.

Sometimes cloud services have a limit on how frequently you can post data. Two seconds seems a bit frequent and it seems that it was successful (or at least didn't show error) once and then the connection was rejected. Perhaps your account has been suspended for a bit for spamming the server.

Thanks for answering. How can I check if that's the case?

For the record, this interval is only when I'm testing. I normally update every 10 minutes. The past weeks I have almost not made any updates, except during troubleshooting.

When you autogenerated your sketch, what interval did it use?

I added a read only, periodic variable, and the default interval when I add such variable is 1 sec. I guess it would be strange if they use default values that they don't allow.

@jammenhva
I have a similar problem with my MKR 1010.
I realized the events by using Interrupt Service Routines as Timers (Library: SAMD_TimerInterrupt) instead of the delay function.
After I put "ArduinoCloud.update()" out of the void loop and into my Interrupt Service Routine, that gets thrown every 1 minute, the timespan before the MQTT connection breaks increased a little bit. Maybe this helps in your case.
I have the same oppinion as @wildbill: The cloud service can not handle the requests too frequently.

I am struggling with that for a few days now and neither did I find a propper solution to get a stable connection to the Cloud running nor did I find a working piece of code for reconnecting successfully after the connection broke.

try to create a new Arduino.cc account, I don't know if it's a matter of banning or certification, but it worked for me, I had tried 3 nano IOT 33 boards, but with all of them it gave me the same error, even opening port 8883 of the modem .

da questa mattina ricevo spesso questo errore nodemcu 1.0
handle_ConnectMqttBroker could not connect to mqtts-up.iot.arduino.cc:8884
e non riesco ad inviare e ricevere comandi
da cosa dipende? fino a ieri funzionava tutto.
grazie

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.