Skip to content

Opta fails to connect to Arduino Cloud: "Mqtt error: -2 TLS error: 304" #534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lobodpav opened this issue Mar 5, 2025 · 7 comments
Closed
Labels
type: imperfection Perceived defect in any part of project

Comments

@lobodpav
Copy link

lobodpav commented Mar 5, 2025

Connectiong to IoT in OPTA fails on

ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to iot.arduino.cc:8885 Mqtt error: -2 TLS error: 304

I have followed the official guide below but no luck.

Recovering Unupdated Devices

If you miss the update deadline, your device will automatically disconnect from Arduino Cloud and will not be able to reconnect again. You can recover it by following these steps:

  1. Connect your device via USB to your computer.
  2. Perform an upload of your sketch using the Arduino Cloud Editor; this will ensure IoTCloud library and all required connectivity credentials on your device
    After performing the upload, your device will again be able to connect to Arduino Cloud and send data.

I uploaded the simple sketch below via USB-C, using:

  1. Arduino IDE, Version: 2.3.5-nightly-20241212
  2. ArduinoIoTCloud, Version 2.4.1
  3. OS: MacOS Sequoia 15.3.1
#include "thingProperties.h"

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

    // Init Thing Properties
    initProperties();

    // Connect to Arduino IoT Cloud
    ArduinoCloud.begin(ArduinoIoTPreferredConnection);

    // Enables information about WiFi and IoT Cloud connection printed to the Serial
    setDebugMessageLevel(DBG_INFO);
    ArduinoCloud.printDebugInfo();
}

void loop() {
    ArduinoCloud.update();
    Serial.println("Hello");
    delay(1000);
}

and I got this output:

21:18:20.646 -> Connection to "MyWifi" failed
21:18:20.647 -> Retrying in  "500" milliseconds
21:18:20.647 -> Hello
21:18:25.985 -> Connected to "MyWifi"
21:18:25.985 -> Hello
21:18:27.073 -> Hello
21:18:29.180 -> ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to iot.arduino.cc:8885 Mqtt error: -2 TLS error: 304
@rjtokenring
Copy link

Hi! From your answer I see you have mentioned Arduino IDE.
As written in the mentioned mail, you need to use Arduino Cloud Editor to recover an not updated device.
Regards

@lobodpav
Copy link
Author

lobodpav commented Mar 6, 2025

Hi! From your answer I see you have mentioned Arduino IDE. As written in the mentioned mail, you need to use Arduino Cloud Editor to recover an not updated device. Regards

I see! I have misinterpreted the information, then. I implied that the updated ArduinoIoTCloud library would fix that.

May I ask:

  1. What does the cloud editor do differently compared to Arduino IDE?
  2. How does the Cloud Editor fix the certificate issue? I tried to upload the certificates from the Certificate Update PR to my Opta, but it did not help.

@rjtokenring
Copy link

Arduino Cloud Editor flow updates the security credentials stored on your IoT device that connect using a Secure Element.

@Bodobolero
Copy link

Bodobolero commented Mar 6, 2025

@rjtokenring
I am using Cloud Editor with Safari on Intel MacOS (current, latest version).
I could not make this combination work to deploy sketch to Arduino Connect RP2040 after I received the email above that it requires a security update.
That is why, like @lobodpav I also used latest libraries from Arduino IDE instead of cloud editor (upgraded everything in Arduino IDE including ArduinoIot library to version 2.4.1), updated firmware using firmware updater etc - which didn't help.

The problem is that you do not document exactly what the cloud editor does what the IDE doesn't and thus nobody can know why you need to use the cloud editor and not the IDE (as was possible in the past).

To add to that

  1. I now used a new Arduino RP2040 with Chrome on Intel MacOs and it worked fine
  2. in the combination with Safari on macOS the following works/doesn't work
  • configuring new devices (like new RP2040) works
  • CreateAgent debug console recognizes the device
  • as soon as you switch to the cloud editor (sketch) the device is NOT recognized and thus you cannot upload the sketch from cloud editor.

@lobodpav
Copy link
Author

lobodpav commented Mar 6, 2025

@rjtokenring Yeah, @Bodobolero summarised it nicely. I do seek some details on what exactly happens in the Cloud Editor and how it is different from the IDE.

I tried to learn details from the PR code, but without proper context, I was unable to understand what was going on.

@lobodpav
Copy link
Author

lobodpav commented Mar 7, 2025

I uploaded the same sketch via the Cloud Editor a few seconds ago.
The result is the same - could not connect to iot.arduino.cc:8885 Mqtt error: -2 TLS error: 304 😢

@lobodpav
Copy link
Author

lobodpav commented Mar 7, 2025

I have finally figured it out.

For anyone else struggling like me, these steps resolved the issue:

  1. Go to Devices in your Arduino Cloud.
  2. Delete the device (three dots at the end of the line). Note: This step will unassociate your device from your things.
  3. Re-add the device. This process seems to upgrade Opta's firmware.
  4. Go to Things in your Arduino Cloud.
  5. Click your thing.
  6. Re-associate Opta with your thing.
  7. Upload your sketch.

@lobodpav lobodpav closed this as completed Mar 7, 2025
@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Mar 8, 2025
@per1234 per1234 changed the title OPTA fails to connect to IoT Opta fails to connect to Arduino Cloud: "Mqtt error: -2 TLS error: 304" Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

4 participants