-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Long wait on MQTT Connect #11
Comments
Hi - thanks for the information. We will have a look and report back. Which chip/board are you using? |
Hi, Custom board with an Infineon XMC4500, ethernet connection. |
Thanks for the update. Are you using v1.0.1 of aws_mqtt_agent.c/aws_mqtt_lib.c? v1.0.1 is the most recent and was uploaded about a week and a half ago. You can find the file version at the top of the file above the license agreement. Have you ported configPRINTF? If so, could you share the log outputs? |
sblancodiez, happy new year! The behavior you're describing also reminds me of a common gotcha that occurs when your device has an otherwise valid AWS IoT credential, but the associated policy in the AWS IoT "Thing" registry is incorrect or incomplete. The resulting behavior in that case is that the device will connect TCP, negotiate TLS, but then immediately be disconnected by the server. Essentially, the authentication succeeds, but the subsequent authorization check fails. If that sounds like possibly what you're observing, can you please review this forum thread? In summary, that thread describes how to use the AWS CLI to double-check "Thing" credential and policy configuration. |
Hi, Right now I can't run it for logging, I will do that when possible. I used both 1.0.0 and 1.0.1 with the same results. The issue is that if when the MQTT task does the first non-blocking recv it does not get data, it sleeps the full timeout value before trying recv again. Since the first recv is called very fast after sending the connect command, and it has a long timeout, you get a very long and not needed wait. I am not using AWS, I am testing against a Mosquitto broker in my local network. Also, I am not using the demo exactly as is; I am using TLS so obviously there is a parameter change in the setup part. Best regards, |
Hello, here's an example of how I tested my own instance of Mosquitto running on the internet. I tested the connection using the Mosquitto pub/sub command-line applications in order to confirm basic routing and connectivity. Then I transferred those settings to my Amazon FreeRTOS device. Start by running the server. I'm using the Windows version and requiring TLS. However, unlike the AWS IoT broker, I'm not requiring TLS certificate client authentication. mosquitto.exe -p 443 -v From the same network that the device is on (i.e., if other than where your server is running), start a subscriber: mosquitto_sub.exe -h xyz.us-west-2.compute.amazonaws.com -p 443 -q 0 -t string/StringTopic Next, publish a message on the same topic from a different client command window: mosquitto_pub.exe -h xyz.us-west-2.compute.amazonaws.com -p 443 -q 0 -t string/StringTopic -m hi Confirm that the message you published is received by your subscriber instance and printed to its console output. Once that's working, transfer the settings to the appropriate code locations in your Amazon FreeRTOS project. For example, the DNS name (or IP address) of your MQTT broker should be assigned to clientcredentialMQTT_BROKER_ENDPOINT in aws_clientcredential.h. In that same file, the port number that your MQTT broker is listening on should be assigned to clientcredentialMQTT_BROKER_PORT. In aws_hello_world.c, ensure that echoCLIENT_ID is unique to your environment. That is, no two MQTT clients should be using the same ID. Ensure that the sixth parameter of your MQTTAgentConnectParams_t is set to pdTRUE if you successfully tested your broker using TLS. Set that field to pdFALSE if you successfully tested your broker with TCP/IP without TLS. Likewise, if you are using TLS, the last two parameters of MQTTAgentConnectParams_t must be your encoded server certificate and its size, respectively. By default, when using TLS, our client libraries enforce server certificate trust verification. |
Yes, all that was already accounted for and it is working. The issue and possible solution is slow connection because how timeouts are managed. Since I did not write the library I just wanted to share that and ask if there is a negative consequence on the change I proposed, but without change it works although I get around 12 seconds of wait in the connect phase and with my change I get no appreciable wait (300ms as written). |
In order to ensure that the MQTT agent wakes up frequently to check if any data is received on the connected socket, you should define the macro mqttconfigMQTT_TASK_MAX_BLOCK_TICKS (in aws_mqtt_agent_config.h) to a smaller value. Note that the frequent wake up of the MQTT agent to check the received data on the connected socket can be avoided if the board has a capability to inform the MCU (probably some interrupt) about the data received on a connected socket. |
In release 1.4.3, PKCS #11 objects switched from being accessed by file name to being accessed by label name. As a result, pkcs11configFILE_NAME_* configs are now a property of the portable PAL layer and are unused in the config file.
In release 1.4.3, PKCS #11 objects switched from being accessed by file name to being accessed by label name. As a result, pkcs11configFILE_NAME_* configs are now a property of the portable PAL layer and are unused in the config file.
PKCS #11 types may follow the format CK_TYPE_PTR or CK_TYPE_PTR_PTR. This change updates the style checker to recognize _PTR and _PTR_PTR line endings as pointer types. This change also allows variables to start with a number.
Modify style checker for PKCS #11 types
[UPDATED] RX65N RSK (Ether) aws_pkcs11_pal.c data storing to FLASH ROM. Signed-off-by: SheltyDog <hiroki.ishiguro.fv@renesas.com>
…t to the PKCS #11 information section.
Add Dan's TLS file for RSA keys (+ substituted key lookup for helpers in aws_pkcs11.c). Add additional configurations to TLS tests for RSA vs EC keys and CreateObject vs GenerateKeyPair for provisioning. Fix RSA Sign PKCS #11 test.
Calls DestroyObject repeatedly on all AWS PKCS #11 Labels until no more objects with that label found.
For multithreading support, created mutex wrappers to match PKCS #11 expected function footprint. Functions calling xInitialzePkcs11Session will get mutex functions (but have not updated for all places that call C_Initialize directly).
Add Dan's TLS file for RSA keys (+ substituted key lookup for helpers in aws_pkcs11.c). Add additional configurations to TLS tests for RSA vs EC keys and CreateObject vs GenerateKeyPair for provisioning. Fix RSA Sign PKCS #11 test.
Calls DestroyObject repeatedly on all AWS PKCS #11 Labels until no more objects with that label found.
…n EC curve was used.
* Submoduled PKCS #11 repo. * Removed PKCS #11 docs. * Removed PKCS #11 wrapper library. * Removed PKCS #11 utils. * Removed implementation. * Moved mbed TLS mutex initialization to the PAL. * Update build systems. * Fixed bug in PKCS #11 integration tests. The wrong size for a known EC curve was used.
…looking for client credentials.
* Allow for TLS basic connections by squashing PKCS #11 errors when looking for client credentials. * Improved error message. * Added changelog snippet. * Add comment to describe the reason behind the change necessary for basic TLS. Co-authored-by: Archit Aggarwal <architag@amazon.com>
) * Remove PKCS #11 PAL destoy object config flag. * Update corePKCS11 submodule. Add Destroy object implementation to ports lacking one.
Hello,
I am playing with Amazon FreeRTOS and when I connect to the broker I observe a delay equal to the timeout value (something like 12 or 14 seconds) before the ACK is processed.
I think the problem is that after sending the connection message the prvManageConnections function does not get anything in the socket read and then sets the next timeout to the full timeout. I think it should check the socket often before waiting for the full time.
Maybe it is a naive fix but I changed in MQTT_Periodic the following:
/* If this Tx operation has not timed out yet, update when the next earliest timeout will happen. */
ulNextTimeoutTicks = mqttMIN( ulNextTimeoutTicks, mqttbufferGET_PACKET_TIMEOUT_TICKS( xBuffer ) );
to the following (including the FreeRTOS header):
/* If this Tx operation has not timed out yet, update when the next earliest timeout will happen. */
ulNextTimeoutTicks = mqttMIN( ulNextTimeoutTicks, 300 / portTICK_PERIOD_MS );
This way, it will check every 300ms for data in the socket instead of waiting.
Is this correct?
The text was updated successfully, but these errors were encountered: