MQTT connection
-
I'm having difficulty connecting my Core Basic to MQTT using UIFlow 2.0. Here are the pertinent code blocks:
When I run it, I get the following error.
umqtt.py line 71. in connectOSerror: -203
Looking at the github, this line is the middle line of this statement for the connection procedure Connect():
if self.user is not None: sz += 2 + len(self.user) + 2 + len(self.pswd) msg[6] |= 0xC0
It also references the line of code for this connection block in my setup:
mqtt_client.connect(clean_session=True)
I'm trying to connect to a Mosquitto broker on a raspberry pi that allows anonymous connection (no user/pass). It appears that error stems from the user/pass variables, but they are set as None in the block so why does this even trigger? Regardless, I'm at an impasse here on how to solve the issue. Any help would be appreciated.
-
Hello @travisstdenis
have you tried to connect to test.mosquitto.org? Does that work or are you getting the same error?
Thanks
Felix -
@travisstdenis The connection blocks need to bee in the loop not the setup.
-
@felmue i couldn't get a connection to test.mosquitto.org but i could for Adafruit. I setup this connection
I get a nonsense error on the screen about some unrelated rectangle UI block in the setup about
TypeError: extra keyword arguments given
When I look at the serial data i get:
>>> E (8014) mqtt_client: Error create mqtt task E (23515) mqtt_client: esp_mqtt_client_init(800): Memory exhausted E (23515) mqtt_client: Client was not initialized E (23516) mqtt_client: Client was not initialized
I have tried this several ways. with and without the https:// in the server, with keepalive values of 0 or 300, in and out of the "if connected to wifi" block. The image shows the only way I've gotten some kind of response that gets me closer.
-
@ajb2k3 I have the "MQTT Apply For Messaging" block in the Loop. Everything I have seen has the connection parts in the Setup. Are you saying I need to have the MQTT Init block from the setup in the Loop?
-
Hello @travisstdenis
please have a look at my example for test.mosquitto.org and io.adafruit.com in the UIFlow2 Project Zone called: M5Core_MQTT_WLAN_UIFlow2.1.4
Thanks
Felix -
@felmue that worked! So it was just the addition of those other WiFi blocks that did it. The Serial output had said Wifi connected before, but I guess not.
-
Hello @travisstdenis
thank you for reporting back. I am glad to hear you got it working.
Thanks
Felix