First thing first, sorry for my bad english
I'm trying to create a MQTT program in python 2.7 that runs under Linux. I'm not a programmer but a automotive mechanic. So keep it simple for me :) It's just a hobby
At the moment i'm using the PAHO-MQTT 1.2.3 package for Python. I got an annoying error and i can't find what i'am doing wrong.
Here is some of the code
def on_connect(client, userdata, flags, rc):
printLine()
printMsg("Connected to server")
printMsg("Address:\t ] %s" % (sServer))
printMsg("Port:\t\t ] %s" % (sPort))
printMsg("Username:\t ] %s" % (sUsername))
#client.subscribe("order/"+sLocation+"/mem")
#client.subscribe("order/"+sLocation+"/in")
printLine()
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.username_pw_set(sUsername,sPassword)
printMsg("marker 1")
time.sleep( 0.3 )
client.connect(sServer, sPort, 60)
time.sleep( 0.3 )
printMsg("marker 2")
client.loop_start()
time.sleep( 0.3 )
printMsg("marker 3")
7 out 10 is OK (print @ linux terminal)
[========================================
[ Booting.....
[ marker 1
[ marker 2
[========================================
[ Connected to server
[ Address: ] *******
[ Port: ] 8883
[ Username: ] *********
[========================================
[ marker 3
[ send
3 out 10 i'm getting the next error in the linux terminal
[========================================
[ Booting.....
[ marker 1
[ marker 2
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2630, in _thread_main
self.loop_forever(retry_first_connection=True)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1410, in loop_forever
rc = self.loop(timeout, max_packets)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 926, in loop
rc = self.loop_read(max_packets)
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1209, in loop_read
rc = self._packet_read()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 1802, in _packet_read
rc = self._packet_handle()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2278, in _packet_handle
return self._handle_publish()
File "/usr/local/lib/python2.7/dist-packages/paho/mqtt/client.py", line 2430, in _handle_publish
(topic, packet) = struct.unpack(pack_format, packet)
error: bad char in struct format
[ marker 3
[ send
Can someone point me in the right direction to fix my error.