aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
978 stars 625 forks source link

Failed to receive data over network: SSL_read failed: ErrorStatus=(null). #1777

Closed Heena2411 closed 2 years ago

Heena2411 commented 2 years ago

Hi I am referring aws-iot-device-sdk-embedded-C SDK and doing below steps.

  1. subscribe to shadow topics
  2. send desired data
  3. send reported data

while trying to run over Wi-Fi network it is working ok. But when I am connecting device with tallit module most of the time getting below error.

[ERROR] [Transport_OpenSSL_Sockets] [openssl_posix.c:817] Failed to receive data over network: SSL_read failed: ErrorStatus=(null). 2021-12-31 12:05:09,696 [ERROR] cloud_app:AWSCloudShadowHelpers.cpp:ExecuteProcessLoop:592=>MQTT_ProcessLoop returned with status = 4. 2021-12-31 12:05:09,696 [ERROR] cloud_app:MQTT_ProcessLoop returned with status = 4.

Is there anything specific to network bandwidth ? May I know what is the exact purpose of MQTT_ProcessLoop() at time of subscribe, publish and unsubscribe ? Is it necessary to call it all 3 time ?

Note : creating multiple named shadows.

AniruddhaKanhere commented 2 years ago

Hello @Heena2411,

I am not sure which device are you working with and which 'Telit module' are you using?

When the status is '4' it means that the receive (recv) has failed to return enough bytes in the given timeout or there has been an error. I don't think that it would be caused by a slow network unless it is extremely slow leading to timeouts.

Can you answer my above questions so that we can work on figuring out the problem?

Thanks

Heena2411 commented 2 years ago

Thanks for the response. I am able to resolve above error by calling MQTT_ProcessLoop() from seperate thread instead of calling it from all 3 API(subscribe, publish, unsubscribe). But sometimes not getting data in eventcallback for one shadow. Attached log file for reference. I have created 2 shadows - shadow and shadow1. after publishing data for shadow1 , didn't get any response.

AWS2.log

archigup commented 2 years ago

Hi, the coreMQTT API is not thread-safe; if you need to use coreMQTT from multiple threads, you could protect access to the coreMQTT API using a mutex or consider using the coreMQTT-Agent instead.

archigup commented 2 years ago

Hey, if you still are having trouble, feel free to create a new issue or reopen this one.

zzl20230617 commented 1 year ago

When I use MQTT core, I can connect to MQTT broker, but SSL_read fail problem: [ERROR] [Transport_OpenSSL_Sockets] [openssl_posix.c:845] Failed to receive data over network: SSL_read failed: ErrorStatus=EVP lib. [ERROR] [MQTT] [core_mqtt.c:1728] Call to receiveSingleIteration failed. Status=MQTTRecvFailed [ERROR] [Transport_OpenSSL_Sockets] [openssl_posix.c:280] SSL_connect failed to perform TLS handshake. [ERROR] [Transport_OpenSSL_Sockets] [openssl_posix.c:696] Failed to establish a TLS connection. [INFO] [MQTT] [core_mqtt.c:2685] MQTT connection established with the broker.

when I use other device certificates and private keys, it works normally, and this non-working certificate works normally yesterday, the only change is that this certificate has been used on devices in other regions before, and after using TLS in other regions, my side can no longer connect to TLS

srinivas1982 commented 1 year ago

same issue i am also facing