I have been using this particular python script for weeks if not longer and it always worked. Last night I did an update to mosquitto. Now I get the failure below. During the update I was given an option to do "something" (sorry, my gray cells are not what they used to be....I don't remember the option). I thought I selected the option that made the most sense. Apparently it was the wrong one. I am hoping someone knows how to undo what I did wrong.
I am using a raspberry pi. The broker_address is 192.168.1.115 = the RPi processor IP.
Note I can open two terminal windows and publish and subscribe successfully
Below is the error message. Below that is a segment of the code.
Connected with result code 60
connecting to broker
Traceback (most recent call last):
File "/var/www/myurl/KBD2Var.py", line 159, in <module>
main()
File "/var/www/myurl/KBD2Var.py", line 96, in main
client.connect(broker_address,1883,60) #connect to broker
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 914, in connect
return self.reconnect()
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 1044, in reconnec sock = self._create_socket_connection()
File "/home/pi/.local/lib/python3.9/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
File "/usr/lib/python3.9/socket.py", line 843, in create_connection
raise err
File "/usr/lib/python3.9/socket.py", line 831, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
------------------
(program exited with code: 1)
Press return to continue
Segment of the code
broker_address="192.168.1.115"
client = mqtt.Client("P1")
client.on_message=on_message
client.on_connect=on_connect(broker_address,1883,60)
print("connecting to broker")
client.connect(broker_address,1883,60) #connect to broker
client.loop_start() #start the loop
#print("Subscribing to topics")
client.subscribe("BackDoor")
client.subscribe("FrontDoor")
client.subscribe("GarageDoor")
[Updated on: Fri, 17 June 2022 21:36]
Report message to a moderator