ARMmbed / mbed-os-example-for-aws

Mbed OS example to connect to AWS IoT Core
Apache License 2.0
15 stars 21 forks source link

At low baud rate, closing MQTT connection causes MQTT and mbedTLS errors #30

Closed evedon closed 3 years ago

evedon commented 3 years ago

Description of defect

There is a race condition on closing the MQTT connection which causes the peer to close the connection first and triggers error handling in MQTT library and error messages in mbedTLS:

[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40) UNSUBSCRIBE operation scheduled.
[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40, UNSUBSCRIBE operation 0x20011FD0) Waiting for operation completion.
[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40, UNSUBSCRIBE operation 0x20011FD0) Wait complete with result SUCCESS.
[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40) Disconnecting connection.
[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40, DISCONNECT operation 0x20010CF0) Waiting for operation completion.
[WARN][AWSPort]: peer closed socket
[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40, DISCONNECT operation 0x20010CF0) Wait complete with result SUCCESS.
[ERROR][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40) Unknown packet type ff received.
[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40) Connection disconnected.
[ERROR][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40) Error processing incoming data. Closing connection.
[INFO][TLSW]: Closing TLS
[ERR ][TLSW]: Socket send error -3012
[ERR ][TLSW]: mbedtls_ssl_close_notify() failed: -0xbc4 (-3012): UNKNOWN ERROR CODE (B80) : UNKNOWN ERROR CODE (44)
[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40) Network connection closed.
[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40) Network connection closed.
[ERROR][MQTT][24 Jan 1985 12:20] _mqttOperation_tryDestroy 0 
[INFO][AWSPort]: Exiting event_dispatcher_thread
[INFO ][MQTT][24 Jan 1985 12:20] (MQTT connection 0x20010C40) Network connection destroyed.
[INFO ][MQTT][24 Jan 1985 12:20] MQTT library cleanup done.
[INFO ][INIT][24 Jan 1985 12:20] SDK cleanup done.
[INFO][Main]: Done

This race condition manifests itself when using a low baud rate (9600).

This does not prevent the example to successfully run through completion.

Target(s) affected by this defect ?

Tested on DISCO_L475VG_IOT01A

Toolchain(s) (name and version) displaying this defect ?

Tested with GCC_ARM

What version of Mbed-os are you using (tag or sha) ?

mbed-os-6.3.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

N/A

How is this defect reproduced ?

Run the example at 9600 baud rate

ciarmcom commented 3 years ago

@evedon thank you for raising this issue.Please take a look at the following comments:

We cannot automatically identify a release based on the version of Mbed OS that you have provided. Please provide either a single valid sha of the form #abcde12 or #3b8265d70af32261311a06e423ca33434d8d80de or a single valid release tag of the form mbed-os-x.y.z . E.g. 'mbed-os-6.3.0,' has not been matched as a valid tag or sha. NOTE: If there are fields which are not applicable then please just add 'n/a' or 'None'.This indicates to us that at least all the fields have been considered. Please update the issue header with the missing information, the issue will not be mirroredto our internal defect tracking system or investigated until this has been fully resolved.

ciarmcom commented 3 years ago

@evedon it has been 5 days since the last reminder. Could you please update the issue header as previously requested?

LDong-Arm commented 3 years ago

Please provide either a single valid sha of the form #abcde12 or #3b8265d70af32261311a06e423ca33434d8d80de or a single valid release tag of the form mbed-os-x.y.z . E.g. 'mbed-os-6.3.0,' has not been matched as a valid tag or sha.

@adbridge It seems the script didn't re-parse the version after the PR description was fixed?

ciarmcom commented 3 years ago

@evedon it has been 5 days since the last reminder. Could you please update the issue header as previously requested?

ciarmcom commented 3 years ago

@evedon it has been 5 days since the last reminder. Could you please update the issue header as previously requested?

ciarmcom commented 3 years ago

Thank you for raising this detailed GitHub issue. I am now notifying our internal issue triagers. Internal Jira reference: https://jira.arm.com/browse/IOTOSM-2951

LDong-Arm commented 3 years ago

Closing this one as we have switched to the new AWS client