Hello Arduino community. I would like to report a problem when connecting the ESP32 WROOM 32 DevKit (DIYMall) to ArduinoCloud. I have been following this tutorial.
I'm able to connect to upload the program, connect to the WiFi but when the ESP32 tries to connect to the ArduinoCloud MQTT server. It fails with the following errors:
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-up.iot.arduino.cc:8884
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 1 connection attempt at tick time 15112
I have tried selecting different boards because I think this is related to client certificates or TLS issues. The boards I tried are:
Hello dbeamonte. Yes, I have introduced WiFi correctly and the Device key too. Please find below the simple sketch I have been testing. It is for monitoring a physical switch on the cloud. Also I turn ON a physical LED to check the switch.
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/def358c3-2179-44ec-b786-ebdf207df1eb
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
bool btnState;
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"
#define BTN1 0
#define LED1 2
void setup() {
pinMode(BTN1, INPUT);
pinMode(LED1, OUTPUT);
digitalWrite(LED1, LOW);
// Initialize serial and wait for port to open:
Serial.begin(115200);
// 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);
/*
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(4);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Your code here
if (!digitalRead(BTN1)) {
btnState = true;
digitalWrite(LED1, HIGH);
delay(150);
} else {
digitalWrite(LED1, LOW);
btnState = false;
}
}
/*
Since BtnState is READ_WRITE variable, onBtnStateChange() is
executed every time a new value is received from IoT Cloud.
*/
void onBtnStateChange() {
// Add your code here to act upon BtnState change
}
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13864
load:0x40080400,len:3608
entry 0x400805f0
***** Arduino IoT Cloud - configuration info *****
Device ID: 449d573b-bcc4-48f3-959b-63f9c4ca5190
MQTT Broker: mqtts-up.iot.arduino.cc:8884
WiFi.status(): 255
Connection to "IoT-B19" failed
Retrying in "4000" milliseconds
Connected to "IoT-B19"
TimeServiceClass::sync Drift: -1694188549 RTC value: 1694188559
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-up.iot.arduino.cc:8884
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 1 connection attempt at tick time 13294
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-up.iot.arduino.cc:8884
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 2 connection attempt at tick time 18261
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-up.iot.arduino.cc:8884
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 3 connection attempt at tick time 27179
I have triple checked the secret key, also I deleted the Device and added it again to generate and configure a new one but the error persists. I don't know if the problem is related to the ESP32 DIYmall version, which is one of the most popular devkits on Amazon. As I have stated before, I think the problem is related with the ssl handshake authentication. Maybe the key certs for this board are not correctly generated.
Hi @dvelaren from which country are you trying to connect your board?
The full tls handshake for ESP32 deviced has been enabled with the 1.12.0 release of the library, and i'm wondering if we should provide different certificates from different countries.
Can you try to connect using 1.11.3 version of the ArduinoIoTCloud library? or reverting this commit?
Hello @pennam I'm connecting from Colombia. I'm using Arduino Cloud to upload the code to the ESP32. I will test by installing directly the ArduinoIoTCloud library into my Arduino IDE and see if with your recommended version works.
@pennam I found now the error. It seems the current WiFi connection I'm using is blocking the MQTT connection. I have used before MQTT with Ubidots for ESP32 without problems in this SSID so it is weird. You can consider this problem solved, I shared my phone's internet with a Hotspot and it worked.
Hello @pennam.
I would like to reopen this issue since it is still happening using with my phone's internet so I think it is related to the ESP32 board and the ArduinoIoTCloud v1.12.2 when generating the required ssl certificates for handshake auth.
I will test again with version v1.11.3 to see if it is fixed and will report back the results so Arduino team can please keep track of a possible bug.
Thanks
Update: I tested now with ArduinoIoTCloud v1.11.3 and v1.11.2 but the issue persists:
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-up.iot.arduino.cc:8884
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 1 connection attempt at tick time 13756
Hi @dvelaren
i suggest you to compile your sketch enabling ESP core debug. Using VERBOSE you should have much more information (on the serial monitor) about the tls handshake and other network issues
Hello pennam, we recently contacted our university ISP and security provider and it seems they were blocking 8884 traffic through the firewall. Also I would like to note that my phone's ISP also started blocking such port as it seems. After we finally managed to unlock the 8884 port with university's internet. So I confirm ArduinoIoTCloud is working correctly.