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
mbedtls_net_connect returned -0x42 , need more info
Re: mbedtls_net_connect returned -0x42 , need more info
You can enable socket debug in lwip https://github.com/espressif/esp-idf/bl ... pts.h#L628
This will print some more information about the sockets set up and the errors
This will print some more information about the sockets set up and the errors
Re: mbedtls_net_connect returned -0x42 , need more info
Hi,
Thank you for the suggestion.
I tried to reduce the number of Max number of open sockets to 12 and disabled SO_REUSEPORT, now i am not getting "mbedtls_net_connect returned -0x42 " error but instead getting
E (227303) aws_iot: failed! mbedtls_ssl_handshake returned -0x2700
E (227303) aws_iot: Unable to verify the server's certificate.
I am not sure why this is happening as the initial connection was successful and was able to publish and subscribe.
In addition to above i tried to run the subcribepublish example from https://github.com/espressif/esp-idf/bl ... h_sample.c standalone as only one task, i did not face any issue on this if i disconnect the LAN wire from WiFi Router and plug it back.
On both instances AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL is set to more than 10 mins (in milliseconds)
I will try to investigate this further,
If anybody has any further suggestion please let me know.
Thank you
Paul
Thank you for the suggestion.
I tried to reduce the number of Max number of open sockets to 12 and disabled SO_REUSEPORT, now i am not getting "mbedtls_net_connect returned -0x42 " error but instead getting
E (227303) aws_iot: failed! mbedtls_ssl_handshake returned -0x2700
E (227303) aws_iot: Unable to verify the server's certificate.
I am not sure why this is happening as the initial connection was successful and was able to publish and subscribe.
In addition to above i tried to run the subcribepublish example from https://github.com/espressif/esp-idf/bl ... h_sample.c standalone as only one task, i did not face any issue on this if i disconnect the LAN wire from WiFi Router and plug it back.
On both instances AWS_IOT_MQTT_MAX_RECONNECT_WAIT_INTERVAL is set to more than 10 mins (in milliseconds)
I will try to investigate this further,
If anybody has any further suggestion please let me know.
Thank you
Paul
Re: mbedtls_net_connect returned -0x42 , need more info
have your certificate settings been freed?
Code: Select all
#define MBEDTLS_ERR_X509_CERT_VERIFY_FAILED -0x2700 /**< Certificate verification failed, e.g. CRL, CA or signature check failed. */
Re: mbedtls_net_connect returned -0x42 , need more info
Hi,
I am now able to connect to aws. I have to disable accelerations under Component config → mbedTLS in menuconfig and now able to test the above scenario.
Thank you
Paul
I am now able to connect to aws. I have to disable accelerations under Component config → mbedTLS in menuconfig and now able to test the above scenario.
Thank you
Paul
Re: mbedtls_net_connect returned -0x42 , need more info
what is accleration setting ? Can you please explain the steps? I am not able to find it
Who is online
Users browsing this forum: Baidu [Spider] and 263 guests