MQTT connection timeout error on CY8PROTO-062-4343W PSoC 6 Amazon FreeRTOS

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
SeVl_4673051
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

Hi,

I've got an issue similar to https://community.cypress.com/thread/52154?q=aws%20iot  AaMo_3399246​ . The issue was locked, but it was not resolved.

I'm using AWS MQTT demo on CY8PROTO-062-4343W PSoC 6 Amazon FreeRTOS (git clone --recurse-submodules https://github.com/cypresssemiconductorco/amazon-freertos.git --branch 201910-MTBAFR1951) and getting MQTT connection timeout error while connecting to AWS IoT Core. I've increased timeout to 60 seconds (in iot_demo_mqtt,c set MQTT_TIMEOUT_MS to 60000 from 5000) and still getting the same error. I'm using ModusToolbox IDE on Ubuntu 18.04 LTE to build/deploy this demo.

Here is the log:

LAN MAC Address : 00:9D:6B:63:76:09

WLAN Firmware    : wl0: Sep  5 2019 23:24:33 version 7.45.98.92 (r722362 CY) FWID 01-f7128517

WLAN CLM         : API: 12.2 Data: 9.10.39 Compiler: 1.29.4 ClmImport: 1.36.3 Creation: 2019-09-05 23:10:00

WHD VERSION      : v1.70.0 : v1.70.0 : GCC 7.2 : 2019-12-02 04:14:53 -0600

.1 5585 [Tmr Svc] Wi-Fi Connected to AP. Creating tasks which use network...

2 5585 [Tmr Svc] IP Address acquired 192.168.1.71

3 7301 [Tmr Svc] Write certificate...

4 7841 [iot_threa] [INFO ][DEMO][lu] ---------STARTING DEMO---------

5 7843 [iot_threa] [INFO ][INIT][lu] SDK successfully initialized.

.6 12654 [iot_threa] [INFO ][DEMO][lu] Successfully initialized the demo. Network type for the demo:7 12654 [iot_threa] [INFO ][MQTT][lu] MQTT library successfully initialized.

8 12654 [iot_threa] [INFO ][DEMO][lu] MQTT demo client identifier is bio01 (length 5).

.9 16322 [iot_threa] [INFO ][MQTT][lu] Establishing new MQTT connection.

10 16324 [iot_threa] [INFO ][MQTT][lu] Anonymous metrics (SDK language, SDK version) will be provid11 16325 [iot_threa] [INFO ][MQTT][lu] (MQTT connection 0x8012778, CONNECT operation 0x800c168) Wai.12 21325 [iot_threa] [INFO ][MQTT][lu] (MQTT connection 0x8012778, CONNECT operation 0x800c168) Wai13 21325 [iot_threa] [ERROR][MQTT][lu] Failed to establish new MQTT connection, error TIMEOUT.

14 21326 [iot_threa] [INFO ][MQTT][lu] Network connection closed on error.

15 21626 [iot_threa] [INFO ][MQTT][lu] (MQTT connection 0x8012778) Network connection destroyed.

16 21626 [iot_threa] [ERROR][DEMO][lu] MQTT CONNECT returned error TIMEOUT.

17 21626 [iot_threa] [INFO ][MQTT][lu] MQTT library cleanup done.

18 21626 [iot_threa] [ERROR][DEMO][lu] Error running demo.

19 21626 [iot_threa] [INFO ][INIT][lu] SDK cleanup done.

20 21626 [iot_threa] [INFO ][DEMO][lu] -------DEMO FINISHED-------

Both of them have the same policy to access AWS IoT Core. I think the issue may be related to clientId/cert/key.

I've got the same error when I used cert/key pair using basicPubSub.py demo code.

python aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py -e awogvrxwfww40-ats.iot.us-east-1.amazonaws.com -r root-CA.crt -c bio2.cert.pem -k bio2.private.key -id bio01

2020-03-31 06:59:17,318 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Initializing MQTT layer...

2020-03-31 06:59:17,320 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Registering internal event callbacks to MQTT layer...

2020-03-31 06:59:17,320 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - MqttCore initialized

2020-03-31 06:59:17,321 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Client id: bio01

2020-03-31 06:59:17,321 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Protocol version: MQTTv3.1.1

2020-03-31 06:59:17,321 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Authentication type: TLSv1.2 certificate based Mutual Auth.

2020-03-31 06:59:17,321 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring endpoint...

2020-03-31 06:59:17,322 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring certificates...

2020-03-31 06:59:17,322 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring reconnect back off timing...

2020-03-31 06:59:17,323 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Base quiet time: 1.000000 sec

2020-03-31 06:59:17,323 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Max quiet time: 32.000000 sec

2020-03-31 06:59:17,323 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Stable connection time: 20.000000 sec

2020-03-31 06:59:17,323 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queueing: max queue size: -1

2020-03-31 06:59:17,324 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queue draining interval: 0.500000 sec

2020-03-31 06:59:17,324 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring connect/disconnect time out: 10.000000 sec

2020-03-31 06:59:17,324 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring MQTT operation time out: 5.000000 sec

2020-03-31 06:59:17,325 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync connect...

2020-03-31 06:59:17,325 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async connect...

2020-03-31 06:59:17,325 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Keep-alive: 600.000000 sec

2020-03-31 06:59:17,326 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Event consuming thread started

2020-03-31 06:59:17,327 - AWSIoTPythonSDK.core.protocol.mqtt_core - DEBUG - Passing in general notification callbacks to internal client...

2020-03-31 06:59:17,327 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in fixed event callbacks: CONNACK, DISCONNECT, MESSAGE

2020-03-31 06:59:17,479 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Starting network I/O thread...

2020-03-31 06:59:17,546 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [disconnect] event

2020-03-31 06:59:17,547 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [disconnect] event

2020-03-31 06:59:17,548 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...

2020-03-31 06:59:17,550 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Cleaning up before stopping event consuming

2020-03-31 06:59:17,551 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Event queue cleared

2020-03-31 06:59:17,551 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Stopping network I/O thread...

2020-03-31 06:59:17,547 - AWSIoTPythonSDK.core.protocol.connection.cores - DEBUG - backOff: current backoff time is: 1 sec.

2020-03-31 06:59:18,554 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Network thread stopped

2020-03-31 06:59:18,555 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Event callbacks cleared

2020-03-31 06:59:18,557 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Event consuming thread stopped

2020-03-31 06:59:18,557 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Exiting dispatching loop...

2020-03-31 06:59:27,481 - AWSIoTPythonSDK.core.protocol.mqtt_core - ERROR - Connect timed out

Traceback (most recent call last):

  File "aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py", line 107, in <module>

    myAWSIoTMQTTClient.connect()

  File "/usr/local/lib/python2.7/dist-packages/AWSIoTPythonSDK/MQTTLib.py", line 513, in connect

    return self._mqtt_core.connect(keepAliveIntervalSecond)

  File "/usr/local/lib/python2.7/dist-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 199, in connect

    raise connectTimeoutException()

AWSIoTPythonSDK.exception.AWSIoTExceptions.connectTimeoutException

But the same basicPubSub.py demo code works fine with another provided key/cert.

python aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py -e awogvrxwfww40-ats.iot.us-east-1.amazonaws.com -r root-CA.crt -c bio2.cert.pem -k bio2.private.key -id basicPubSub

2020-03-31 07:01:08,513 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Initializing MQTT layer...

2020-03-31 07:01:08,514 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Registering internal event callbacks to MQTT layer...

2020-03-31 07:01:08,515 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - MqttCore initialized

2020-03-31 07:01:08,515 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Client id: basicPubSub

2020-03-31 07:01:08,516 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Protocol version: MQTTv3.1.1

2020-03-31 07:01:08,516 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Authentication type: TLSv1.2 certificate based Mutual Auth.

2020-03-31 07:01:08,517 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring endpoint...

2020-03-31 07:01:08,517 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring certificates...

2020-03-31 07:01:08,517 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring reconnect back off timing...

2020-03-31 07:01:08,518 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Base quiet time: 1.000000 sec

2020-03-31 07:01:08,518 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Max quiet time: 32.000000 sec

2020-03-31 07:01:08,518 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Stable connection time: 20.000000 sec

2020-03-31 07:01:08,518 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queueing: max queue size: -1

2020-03-31 07:01:08,519 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring offline requests queue draining interval: 0.500000 sec

2020-03-31 07:01:08,520 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring connect/disconnect time out: 10.000000 sec

2020-03-31 07:01:08,520 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Configuring MQTT operation time out: 5.000000 sec

2020-03-31 07:01:08,521 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync connect...

2020-03-31 07:01:08,521 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async connect...

2020-03-31 07:01:08,521 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Keep-alive: 600.000000 sec

2020-03-31 07:01:08,522 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Event consuming thread started

2020-03-31 07:01:08,522 - AWSIoTPythonSDK.core.protocol.mqtt_core - DEBUG - Passing in general notification callbacks to internal client...

2020-03-31 07:01:08,523 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in fixed event callbacks: CONNACK, DISCONNECT, MESSAGE

2020-03-31 07:01:08,710 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Starting network I/O thread...

2020-03-31 07:01:08,803 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [connack] event

2020-03-31 07:01:08,806 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [connack] event

2020-03-31 07:01:08,807 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - No need for recovery

2020-03-31 07:01:08,809 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...

2020-03-31 07:01:08,826 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync subscribe...

2020-03-31 07:01:08,826 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Adding a new subscription record: sdk/test/Python qos: 1

2020-03-31 07:01:08,828 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom suback event callback...

2020-03-31 07:01:08,878 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [suback] event

2020-03-31 07:01:08,879 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [suback] event

2020-03-31 07:01:08,880 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...

2020-03-31 07:01:08,881 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...

2020-03-31 07:01:10,896 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish...

2020-03-31 07:01:10,898 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...

2020-03-31 07:01:10,958 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event

2020-03-31 07:01:10,960 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event

2020-03-31 07:01:10,961 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...

2020-03-31 07:01:10,963 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...

2020-03-31 07:01:10,974 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event

2020-03-31 07:01:10,975 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event

Received a new message:

{"message": "Hello World!", "sequence": 0}

from topic:

sdk/test/Python

--------------

2020-03-31 07:01:10,977 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...

2020-03-31 07:01:11,964 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing sync publish...

2020-03-31 07:01:11,966 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...

2020-03-31 07:01:12,017 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event

2020-03-31 07:01:12,019 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event

2020-03-31 07:01:12,021 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...

2020-03-31 07:01:12,021 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...

2020-03-31 07:01:12,048 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [message] event

2020-03-31 07:01:12,050 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [message] event

Received a new message:

{"message": "Hello World!", "sequence": 1}

from topic:

sdk/test/Python

--------------

Please advise.

0 Likes
1 Solution
SeVl_4673051
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

I've resolved the issue. Somehow I haven't activated the certificate attached to my thing. I've activated it from IoT console (Thing->Security->Certificate->Actions->Activate) and all start working.

I'm wondering if AaMo_3399246​ had the same solution.

View solution in original post

1 Reply
SeVl_4673051
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

I've resolved the issue. Somehow I haven't activated the certificate attached to my thing. I've activated it from IoT console (Thing->Security->Certificate->Actions->Activate) and all start working.

I'm wondering if AaMo_3399246​ had the same solution.