[solved]A umqtt problem thanks

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
yafengabc
Posts: 8
Joined: Thu Mar 08, 2018 8:38 am

[solved]A umqtt problem thanks

Post by yafengabc » Sat Mar 31, 2018 10:42 am

Hi all:
I connect my mqtt server with umqtt。
I have two mqtt servers,one is on Raspberry Pi,the version is 1.4.15 and the other is on bandwagon vps,the version is old :

mosquitto/trusty-updates,trusty-security,now 0.15-2ubuntu1.2 i386 [installed]
MQTT version 3.1 compatible message broker

old but support MQTT v 3.1

the umqtt can work with my mqtt server on raspberry pi very well,but with my vps not working。
the error is:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "<stdin>", line 2, in <module>
File "<string>", line 11, in <module>
File "simple.py", line 97, in connect
IndexError: bytes index out of range

the line 97 in simple.py is:
96 resp = self.sock.read(4)
97 assert resp[0] == 0x20 and resp[1] == 0x02
98 if resp[3] != 0:
99 raise MQTTException(resp[3])
100 return resp[2] & 1

an i insert a "print(resp)" to watch the result
if connect to raspberry pi ,this result is b"\x20\x00\x00"
but connect with bandwagong vps,the result is b""
who can help me test my host?
my vps host ip is :104.160.34.189
thanks
Last edited by yafengabc on Tue Apr 03, 2018 2:49 am, edited 1 time in total.

yafengabc
Posts: 8
Joined: Thu Mar 08, 2018 8:38 am

Re: A umqtt problem thanks

Post by yafengabc » Sat Mar 31, 2018 12:14 pm

I compiled a unix version of micropython,and have the same problem:

Code: Select all

>>> c=MQTTClient('mq','192.168.43.30')
>>> c.connect()
0
>>> c.publish('led','hi')
>>> c=MQTTClient('mq','104.160.34.189')
>>> c.connect()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "umqtt/simple.py", line 97, in connect
IndexError: bytes index out of range

but i can use command:
mosquitto_pub -h 104.160.34.189 -m "hello" -t "led"
to publish the message

yafengabc
Posts: 8
Joined: Thu Mar 08, 2018 8:38 am

Re: A umqtt problem thanks

Post by yafengabc » Sat Mar 31, 2018 12:48 pm

Maybe this is not a problem with the library
I had install paho-mqtt in python 3.6,and tested the mqtt server on my vps
and unable to publish message too
later I update the mosquitto test

btw: mosquitto_pub and some android app eg. ioT MQTT panel can use it.

Post Reply