ESP32 problems connecting to AWS IoT

lawlhwut
Posts: 2
Joined: Wed Nov 29, 2017 5:27 am

ESP32 problems connecting to AWS IoT

Postby lawlhwut » Wed Nov 29, 2017 5:32 am

Hi,

I'm working on a project where the ESP32 connects to wifi, gathers data from its sensors, converts sensor data to units, compiles a MQTT message, connects to AWS IoT, and publishes it to a topic. It connects to Wifi just fine, and I am able to see it on my router. The 3 key and cred files are in its proper directory, but I keep getting this error message:

Code: Select all

I (293) wifi: wifi firmware version: 59e5fab
I (293) wifi: config NVS flash: enabled
I (293) wifi: config nano formating: disabled
I (293) system_api: Base MAC address is not set, read default base MAC address f
rom BLK0 of EFUSE
I (303) system_api: Base MAC address is not set, read default base MAC address f
rom BLK0 of EFUSE
I (333) wifi: Init dynamic tx buffer num: 32
I (333) wifi: Init data frame dynamic rx buffer num: 32
I (333) wifi: Init management frame dynamic rx buffer num: 32
I (343) wifi: wifi driver task: 3ffbf0e0, prio:23, stack:4096
I (343) wifi: Init static rx buffer num: 10
I (343) wifi: Init dynamic rx buffer num: 32
I (353) wifi: wifi power manager task: 0x3ffc5460 prio: 21 stack: 2560
I (363) subpub: Setting WiFi configuration SSID TP-LINK_46DD56...
W (363) phy_init: failed to load RF calibration data (0x1102), falling back to f
ull calibration
I (533) phy: phy_version: 366.0, ba9923d, Oct 31 2017, 18:06:17, 0, 2
I (543) wifi: mode : sta (30:ae:a4:02:49:44)
I (1273) wifi: n:6 2, o:1 0, ap:255 255, sta:6 2, prof:1
I (1573) gps: CHAR ?`?8
Latitude is  ,  . Longitude is  ,  .
before
I (2253) wifi: state: init -> auth (b0)
after
fail to read from sensor
I (2253) subpub: AWS IoT SDK Version 2.1.1-
I (2253) wifi: state: auth -> assoc (0)
I (2263) wifi: state: assoc -> run (10)
I (2423) wifi: connected with TP-LINK_46DD56, channel 6
I (4233) event: sta ip: 192.168.0.101, mask: 255.255.255.0, gw: 192.168.0.254
I (4233) subpub: Connecting to AWS...
E (4403) aws_iot: failed! mbedtls_net_connect returned -0x52
E (4403) subpub: Error(-23) connecting to :8883
I (5263) wifi: pm start, type:0

E (5563) aws_iot: failed! mbedtls_net_connect returned -0x52
E (5563) subpub: Error(-23) connecting to :8883
E (6723) aws_iot: failed! mbedtls_net_connect returned -0x52
E (6723) subpub: Error(-23) connecting to :8883
E (7883) aws_iot: failed! mbedtls_net_connect returned -0x52
E (7883) subpub: Error(-23) connecting to :8883
E (9043) aws_iot: failed! mbedtls_net_connect returned -0x52
E (9043) subpub: Error(-23) connecting to :8883
E (10203) aws_iot: failed! mbedtls_net_connect returned -0x52
E (10203) subpub: Error(-23) connecting to :8883
and the number next to E keeps increasing. I was not able to find any search results pertaining to -0x52. Anybody know how to fix this?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP32 problems connecting to AWS IoT

Postby kolban » Wed Nov 29, 2017 3:05 pm

My guess would be that the ESP32 can't reach the AWS server by its hostname or IP address. This is through the connection failed error message. The return code of -23 decimal might be an encoding of errno of 23 which is ENFILE ... too many files open. The "number" beside the message type which keeps increasing is the time in milliseconds since ESP32 boot ... so it would make sense that it always increases.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

lawlhwut
Posts: 2
Joined: Wed Nov 29, 2017 5:27 am

Re: ESP32 problems connecting to AWS IoT

Postby lawlhwut » Thu Nov 30, 2017 2:31 am

You were right. The hostname was not correct. After correcting it, it started to connect! Thank you very much.

Who is online

Users browsing this forum: No registered users and 62 guests