The MQTT protocol provides minimal feedback, and error messages are limited. Use these steps to troubleshoot a connection and publish messages. The steps are all independent possibilities, but they are listed with the most likely problems listed first.
Ensure that the client address is
you incorrectly configure your client to connect to the ThingSpeak™ MQTT broker,
your connection request is rejected.
Check that you have the correct topic API Key. For MQTT publish, your topic must contain the Write API Key.
Make sure your QoS is set to 0. Some devices have a default QoS that is different than 0. Some clients require you manually change the setting.
Do not set
CleanSession flag to 0. If you set the
CleanSession flag to 0 on your MQTT client, any
connection request to the ThingSpeak™ MQTT broker is rejected with a
"0x05 Connection Refused, not authorized".
Make sure that the port is correct. See MQTT Client Configuration for a list of accepted ports.
Do not set the
Will flag to nonzero values on your MQTT
client. Any connection request to the ThingSpeak MQTT broker with nonzero
Will flag is rejected
CONNACK status of
"0x05 Connection Refused,
If you are having trouble connecting with SSL, be aware that your client can require extra steps to enable a secure connection.