# STM32L4 Discovery Kit - Cannot connect to MQTT broker

**URL:** <https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866>\
**Category:** AWS\
**Created:** [September 3, 2018, 3:36am UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866 "2018-09-03T03:36:58Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 3, 2018, 3:36am UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/1 "2018-09-03T03:36:58Z")

</div>

**[Bread](https://forums.aws.amazon.com/profile.jspa?userID=461945)** 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 ([https://docs.aws.amazon.com/ko\_kr/freertos/latest/userguide/what-is-amazon-freertos.html](https://docs.aws.amazon.com/ko_kr/freertos/latest/userguide/what-is-amazon-freertos.html))  
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

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [September 4, 2018, 5:44pm UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/2 "2018-09-04T17:44:04Z")

</div>

**[Gaurav-Aggarwal-AWS](https://forums.aws.amazon.com/profile.jspa?userID=447386)** 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: [https://docs.aws.amazon.com/freertos/latest/userguide/getting\_started\_st.html#st-troubleshooting](https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_st.html#st-troubleshooting)

Thanks.

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

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [September 5, 2018, 10:56am UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/3 "2018-09-05T10:56:48Z")

</div>

**[Bread](https://forums.aws.amazon.com/profile.jspa?userID=461945)** 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

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [September 5, 2018, 5:30pm UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/4 "2018-09-05T17:30:50Z")

</div>

**[Gaurav-Aggarwal-AWS](https://forums.aws.amazon.com/profile.jspa?userID=447386)** 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.

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 16, 2018, 2:59pm UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/5 "2018-10-16T14:59:46Z")

</div>

**[Bread](https://forums.aws.amazon.com/profile.jspa?userID=461945)** 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?

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [October 16, 2018, 7:39pm UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/6 "2018-10-16T19:39:03Z")

</div>

**[Gaurav-Aggarwal-AWS](https://forums.aws.amazon.com/profile.jspa?userID=447386)** 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.

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 17, 2018, 12:12am UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/7 "2018-10-17T00:12:24Z")

</div>

**[Bread](https://forums.aws.amazon.com/profile.jspa?userID=461945)** 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 192.168.0.10 7 4111 Creating MQTT Echo Task… 8 4115 MQTT echo attempting to connect to [atjr60ltg2wvn.iot.us-east-1.amazonaws.com](http://atjr60ltg2wvn.iot.us-east-1.amazonaws.com). 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

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [October 19, 2018, 6:34pm UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/8 "2018-10-19T18:34:45Z")

</div>

**[Gaurav-Aggarwal-AWS](https://forums.aws.amazon.com/profile.jspa?userID=447386)** 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: [https://github.com/aws/amazon-freertos/blob/master/lib/mqtt/aws\_mqtt\_agent.c#L985](https://github.com/aws/amazon-freertos/blob/master/lib/mqtt/aws_mqtt_agent.c#L985)
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?

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 29, 2018, 1:02pm UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/9 "2018-10-29T13:02:24Z")

</div>

**[Bread](https://forums.aws.amazon.com/profile.jspa?userID=461945)** 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.  
then  
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

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [October 29, 2018, 5:22pm UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/10 "2018-10-29T17:22:32Z")

</div>

**[Gaurav-Aggarwal-AWS](https://forums.aws.amazon.com/profile.jspa?userID=447386)** 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?

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [October 30, 2018, 12:10am UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/11 "2018-10-30T00:10:36Z")

</div>

**[Bread](https://forums.aws.amazon.com/profile.jspa?userID=461945)** wrote on October 30, 2018:

I’m running with USE\_OFFLOAD\_SSL disabled

of course i want!

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [October 31, 2018, 12:17am UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/12 "2018-10-31T00:17:41Z")

</div>

**[Gaurav-Aggarwal-AWS](https://forums.aws.amazon.com/profile.jspa?userID=447386)** wrote on October 31, 2018:

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

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 4, 2018, 11:48am UTC](https://forums.freertos.org/t/stm32l4-discovery-kit-cannot-connect-to-mqtt-broker/8866/13 "2018-11-04T11:48:08Z")

</div>

**[Bread](https://forums.aws.amazon.com/profile.jspa?userID=461945)** wrote on November 04, 2018:

I checked my inbox  
please reply my mail
