Page 1 of 1

MQTTClient erroring

Posted: Mon Nov 19, 2018 1:03 am
by rp346@njit.edu
I am trying to connect to mqtt using umqtt.simple, here is my code

Code: Select all

from umqtt.simple import MQTTClient
SERVER_1 = "p44.cloudmqtt.com"
PORT_1 = 154321
USER_1 = b'user1'
PASSWORD_1 = b'0FVn7NrUPpd5'

DEVICE_ID = ubinascii.hexlify(machine.unique_id())

mqtt1 = MQTTClient(DEVICE_ID, SERVER_1, user=USER_1, password=PASSWORD_1, port=PORT_1)
mqtt1.connect()
Getting following error

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "umqtt/simple.py", line 99, in connect
MQTTException: 5
Any idea whats wrong here ?

Re: MQTTClient erroring

Posted: Mon Nov 19, 2018 5:44 am
by pythoncoder
It would seem that the broker is is rejecting your connection credentials. When you connect it sends a 4 byte CONNACK packet. Bytes 0 and 1 must have been correct, otherwise the code would have thrown an assertion fail. However byte 3 must have had the value 5 for the code to throw that exception. Section 3.2.2.3 of the MQTT spec show that this bit pattern signifies "connection refused, identifier rejected", "The Client identifier is correct UTF-8 but not allowed by the server".

Re: MQTTClient erroring

Posted: Thu Nov 22, 2018 4:28 pm
by rp346@njit.edu
Thanks