micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

User problem with umqtt.simple

Open dmarkey opened this issue 7 years ago • 12 comments

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

dmarkey avatar Sep 21 '16 12:09 dmarkey

latest micropython.. unix port

dmarkey avatar Sep 21 '16 13:09 dmarkey

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?

phieber avatar Oct 01 '16 06:10 phieber

@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.

andrisarkameru avatar Oct 10 '16 19:10 andrisarkameru

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

SquallHalle avatar Oct 12 '16 20:10 SquallHalle

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

pfalcon avatar Oct 13 '16 12:10 pfalcon

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

phieber avatar Oct 15 '16 11:10 phieber

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 "", line 1, in File "umqtt/simple.py", line 84, in connect IndexError: bytes index out of range

BigMan200 avatar Oct 30 '16 11:10 BigMan200

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 avatar Oct 30 '16 13:10 mkarliner

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 ...

BigMan200 avatar Oct 30 '16 13:10 BigMan200

Sorry, I was referring to dmarkey.com in the original post.

mkarliner avatar Oct 30 '16 13:10 mkarliner

in my case,I write wrong port case this error,please check your emqttx port one more time!!

timsengit avatar Sep 06 '22 16:09 timsengit

Wow that must be some kind of record for length of time between comments!

mkarliner avatar Sep 06 '22 17:09 mkarliner