Has anyone sucessfuly used the MQTT blocks in the IDE App's Visual Coding Environment?
I set up a local MQTT broker and configured it in the tiger editor. However, when I try to subscribe or publish a message, I get an error "1234 NameError("name 'url' is not defined",)" threw by the get_connected_client function of the mqtt class:
def get_connected_client(self): if not self.connect_started: self.connect_started = True self.client.connect(url, port) threading.Thread(target=self.client.loop_forever).start() return self.client
It seems that the mqtt object does not recognize the url variable, which might be caused by the fact that this value is not stored in the __init__ function:
def __init__(self, url, port, encrypted): self.client = paho_mqtt_client.Client('tiger') self.client.on_message = lambda client, userdata, message: events.emit( 'mqtttopic' + message.topic, 'message', message.payload.decode("utf-8")) if encrypted: self.client.tls_set() proxy = os.environ.get('HTTP_PROXY') or os.environ.get('http_proxy') if proxy: proxy = re.search(r"^\w*:\/\/(.*):(\d*)", proxy) self.client.proxy_set(proxy_type=3, proxy_addr=proxy.group(1), proxy_port=int(proxy.group(2)))
I tried to adjust the code in the textual coding envirnoment but it did not change the code stored in the blocks. Has anyone encountered (and hopefully solved) a similar issue?
Solved! Go to Solution.