I want to connect ESP32 to demo thingsboard using MQTT and I've used umqtt.simple to connect to it but there's a problem. Whenever I try to connect it gives me either this (File "umqtt/simple.py", line 99, in connect), OR (File "umqtt/simple.py", line 57, in connect IndexError: list index out of range), which I believe they are the same. Although when I tried to connect ESP32 to thingspeak (with some edits) it connected, sent and received data very well. So what is the problem?
My code:
import machine
import time
from machine import Pin, PWM
from umqtt.simple import MQTTClient
from time import sleep
import random
import json
import network
#################MQTT###################
def connect():
username="USER_NAME"
broker= "demo.thngsboard.io"
topic = "v1/devices/me/telemetry"
client = MQTTClient(username,broker)
try:
print("uuuuuuuuuu")
client.connect()
except OSError:
print('Connection failed')
sys.exit()
data = dict()
data["see"] = 15
data2=json.dumps(data)#convert it to json
print('connection finished')
client.publish(topic,data2)
print("kkkkkkkkkkkkkkkkkk")
time.sleep(5)
#print("Sending OFF")
connect()
Please note that I've seen that Question on micropython but it didn't fix my problem: https://forum.micropython.org/viewtopic.php?t=4412 also I've seen that question in which he had A similar problem but he solved it without providing the solution: Device not connecting to Thingsboard using MQTT
AND for sure I'm connecting it to the internet.