Closed Josverl closed 6 years ago
Just to make sure I did a q&d change to modmqtt to hardcode both lwttopic and lwtmessage to empty strings; after doing that the mqtt client is indeed able to connect to thingspeak
#Do not set CleanSession flag to 0 --> cleansession=True)
client = network.mqtt( 'client_10713646',
"mqtt.thingspeak.com",
user='jos',
password=thingspeakMqttApiKey
,cleansession=True)
client
Mqtt[client_10713646](Server: mqtt.thingspeak.com:1883, Status: Disconnected
Client ID: mpy_mqtt_client, Clean session=True, Keepalive=120 sec, QoS=0, Retain=False, Secure=False
)
>>>
>>> client
Mqtt[client_10713646](Server: mqtt.thingspeak.com:1883, Status: Connected
Client ID: mpy_mqtt_client, Clean session=True, Keepalive=120 sec, QoS=0, Retain=False, Secure=False
Used stack: 1048/2048 + 412/2048
)
>>>
Thanks for the suggestions.
I'm planning mqtt module update for the next week, an I'll try to include your suggestions.
Great to know because I can only connect to CloudMQTT and my own mosquitto broker.
Tested for Ubidots and Adafruit, both [Mqtt client]: Connection refused, not authorized
It is working for CloudMQTT, test.mosquitto.org both MQTT and MQTT TLS
I have tried Josverl modmqtt.c, but I don't see a difference. I even tried :
>>> mqtt.config(lwt_topic="")
>>> mqtt.config(lwt_msg="")
>>> mqtt.start()
>>> W (822309) [Mqtt client]: Connection refused, not authorized
Update :
I was able to connect and send data to ThingSpeak, but not to Ubidots. I will reach to them to see why.
Benoit
Currently the MQTT client is hardcoded to request for a lwt on connect. several public mqtt services to not support this , and will reject the connection. (see also issue #81 ) See :
The only known workaround is currently to use the stock micropython mqtt modules.
To improve usability of the builtin module 2 parameters could be added :
from my understanding of the code, such a change could be made in modmqtt.c
modmqtt.c
mqtt_msg.c