STM32L4 Discovery Kit - Cannot connect to MQTT broker

Bread wrote on September 03, 2018:

I’ve been working on the AWS example with the above mentioned STM32 board but I have problems to connect MQTT.
I have been following this document (
config END_POINT, WiFi connection in aws_clientcredential.h
then I generate key, overwrite aws_clientcredential_key.h
but my board cannot connect to mqtt broker.

I’m using WPA2 AP, woking on system workbench for STM32

Is firmware upgrade necessary?

somebody help me, please

Edited by: bbangbin97 on Sep 2, 2018 8:39 PM

Gaurav-Aggarwal-AWS wrote on September 04, 2018:

Yes, it is necessary to update the WiFi module’s firmware. You can follow the instructions here to update the firmware:


Edited by: Gaurav-Aggarwal-AWS on Sep 4, 2018 10:44 AM

Bread wrote on September 05, 2018:

i tried but errors occur.
below is error messages

Activating Device
No response from the target, the boot loader can not be started
Please, verify the boot mode configuration, reset your device then try again.
Please, reset your device then press any key to continue

Gaurav-Aggarwal-AWS wrote on September 05, 2018:

Do you have anything else connected to the device - Please make sure that STM workbench, Terminal program etc. are all closed while you try to update the WiFi firmware.

You can remove the project level define USE_OFFLOAD_SSL and then the code should work with the old firmware as well. However, it will significantly impact performance as it will start doing TLS in software. We highly recommend updating the WiFi firmware.


Bread wrote on October 16, 2018:

The TCP/IP communication test was successful.
I don’t think this is a Wi-Fi issue.

Do you have other solution?

Gaurav-Aggarwal-AWS wrote on October 16, 2018:

Did you try with USE_OFFLOAD_SSL removed? Would you please share your logs to enable us help you better.


Bread wrote on October 17, 2018:

I already try that

logs are here


0 523 WiFi module initialized.
1 527 Starting key provisioning…
2 531 Write root certificate…
3 544 Write device private key…
4 1000 Key provisioning done…
5 4102 WiFi connected to AP ENSA2.
6 4106 IP Address acquired
7 4111 Creating MQTT Echo Task…
8 4115 MQTT echo attempting to connect to
9 4123 Sending command to MQTT task.
10 4128 Received message 10000 from queue.
11 4201 About to close socket.
12 4215 Socket closed.
13 4218 Notifying task.
14 4220 Command sent to MQTT task failed.
15 4225 ERROR: MQTT echo failed to connect.
16 4230 MQTT echo test could not connect to broker.
17 4236 Sending command to MQTT task.
18 4241 Received message 20000 from queue.
19 4245 Notifying task.
20 4248 Command sent to MQTT task passed.
21 4253 MQTT echo demo finished.
22 4257 ----Demo finished----

thank you very much

Edited by: bbangbin97 on Oct 16, 2018 5:21 PM

Gaurav-Aggarwal-AWS wrote on October 19, 2018:

Thank you for sharing the logs. Looking at the logs, there can be two possibilities:

  1. The TCP connection is not successful. Please put a breakpoint in prvSetupConnection function in the file aws_mqtt_agent.c to see if the connection is successful. You can do so by examining the value of xStatus:
  2. The TCP connection is successful but MQTT connection is not. This can happen if the policy is not correctly setup. Would you please share your policy document attached to the certificate you are using?


Bread wrote on October 29, 2018:

I test with your advise then I put a break point in function prvSetupConnection
so, function SOCKETS_Connect fail.

a month ago ,I tried to see if there is a problem with socket communication.

I code the socket program myself.
The board communicated well with the Linux server when testing with the socket communication program.

Here is my Policy

“Version”: “2012-10-17”,
“Statement”: [
“Effect”: “Allow”,
“Action”: “iot:",
“Resource”: "


Edited by: bbangbin97 on Oct 29, 2018 6:26 AM

Gaurav-Aggarwal-AWS wrote on October 29, 2018:

So it is a socket connection problem. Would you please step into the SOCKETS_Connect function and see at what step it fails? Are you running with USE_OFFLOAD_SSL enabled or disabled?

Do you want to set up a remote debugging session to debug this issue?


Bread wrote on October 30, 2018:

I’m running with USE_OFFLOAD_SSL disabled

of course i want!

Gaurav-Aggarwal-AWS wrote on October 31, 2018:

Sure. Sent you a message. Please check your inbox.


Bread wrote on November 04, 2018:

I checked my inbox
please reply my mail