micropython-lib
micropython-lib copied to clipboard
User problem with umqtt.simple
Version: 0.15.-2
client = umqtt.MQTTClient("sddsdsd", "dmarkey.com", 1883) client.connect() Traceback (most recent call last): File "
", line 1, in File "umqtt.py", line 84, in connect IndexError: bytes index out of range
latest micropython.. unix port
Have you tried to connect from the very same subnet to the broker, using another client like an Android App? Are you using the ESP-01 with 8Mb flash?
@dmarkey
By the provided umqtt.simple samples I think you have to use b"sddsdsd"
and b"dmarkey.com"
instead of the strings you provided as your test sample.:
client = umqtt.MQTTClient(b"sddsdsd", b"dmarkey.com", 1883)
The same applies to the strings you post and topics you subscribe to using the umqtt.simple library.
I recently just started to fiddle with the esp8266 myself and this worked for me.
Same here. ESP8266:
def FUU():
c = MQTTClient(b"umqtt_client", b"10.0.0.5", 1883)
c.connect()
c.publish(b"foo_topic", b"hello")
c.disconnect()
File "umqtt.py", line 44, in connect IndexError: bytes index out of range
umqtt.simple definitely works with Mosquitto, that's how it was developed and how it's being tested. There're (official, working) examples provided at the same place where umqtt.simple lives: https://github.com/micropython/micropython-lib/tree/master/umqtt.simple
Other related information: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html
I can also confirm that it works with Mosquitto (>=1MB ESP8266 Flash). Reliably over serveral days is a different story though ;) But that's where umqtt.robust comes into play
I also do not get it working:
'>> c = umqtt.simple.MQTTClient(b"client", b"10.0.0.32", 1883)
'>>> c.connect()
Traceback (most recent call last):
File "
I've taken the liberty of trying this with your (open to the Internet) broker. Sorry for the intrusion. This works fine for me. Have you imported the MQTT package from your main? If so, it probably won't work, as the ESP doesn't have enough memory to compile MQTT. However, that being said, it usually manifests itself as a memory allocation error. I was using a custom build with MQTT simple frozen in the modules directory of the build.
mkarliner: did you connect with my mqtt-broker??? If yes: cool and I have no problem with that "intrusion". BUT: what URL did you use? I mean, above I "only" provided 10.0.0.32 ... which is the "internal" LAN-IP ...
Sorry, I was referring to dmarkey.com in the original post.
in my case,I write wrong port case this error,please check your emqttx port one more time!!
Wow that must be some kind of record for length of time between comments!