mbedtls_net_connect returned -0x42 , need more info
Posted: Thu Jun 29, 2017 3:46 pm
Hi All,
I have several tasks running on esp32, in which two of them are socket server and mqtt connection to aws (same as https://github.com/espressif/esp-idf/bl ... h_sample.c)
I have enabled SO_REUSEADDR, SO_REUSEPORT and Max number of open sockets to 16(max as per the help info) in menu config.
I was testing a scenario as follows:
1. Successfully flashed without any error to esp32 with highest priority for mqtt tasks and others at same priority lower than mqtt task.
2. Successfully connected to aws iot. Able to publish and subscribe.
-- autoreconnect set to true with available disconnectCallbackHandler.
3. Remove LAN wire from WiFi router, wait for 5 minutes.
4. Now once i plug back the LAN Wire , the mqtt task tries to reconnect using disconnectCallbackHandler but fails with "mbedtls_net_connect returned" -0x42 (-0x0042 /**< Failed to open a socket. */ from mbedtls/net.h), did try to increase the stack of the task , but on the second attempt fails
I Assume that by the time the mqtt task tries to reconnect all the sockets are in use and hence this fails , Is there a way to bind a port to mbedtls permanently for mqtt connection and aslo is there any way to use LINGER settings on the sockets?
Any suggestion will be very helpful
Thank you
Paul
I have several tasks running on esp32, in which two of them are socket server and mqtt connection to aws (same as https://github.com/espressif/esp-idf/bl ... h_sample.c)
I have enabled SO_REUSEADDR, SO_REUSEPORT and Max number of open sockets to 16(max as per the help info) in menu config.
I was testing a scenario as follows:
1. Successfully flashed without any error to esp32 with highest priority for mqtt tasks and others at same priority lower than mqtt task.
2. Successfully connected to aws iot. Able to publish and subscribe.
-- autoreconnect set to true with available disconnectCallbackHandler.
3. Remove LAN wire from WiFi router, wait for 5 minutes.
4. Now once i plug back the LAN Wire , the mqtt task tries to reconnect using disconnectCallbackHandler but fails with "mbedtls_net_connect returned" -0x42 (-0x0042 /**< Failed to open a socket. */ from mbedtls/net.h), did try to increase the stack of the task , but on the second attempt fails
I Assume that by the time the mqtt task tries to reconnect all the sockets are in use and hence this fails , Is there a way to bind a port to mbedtls permanently for mqtt connection and aslo is there any way to use LINGER settings on the sockets?
Any suggestion will be very helpful
Thank you
Paul