1

When I was trying out a tutorial in the internet, I failed to connect to the mqtt broker - anyone can help me on that?

import paho.mqtt.client as mqtt

broker_url = "mqtt.eclipse.org"
broker_port = 1883
client = mqtt.Client()
client.connect(broker_url, broker_port)
print(client)
Traceback (most recent call last):  
  File "C:\Workspace\FI Systemintegration\Python\MitarbeiterVerwaltung\rpi\connect.py",   line 6, in <module>  
    client.connect(broker_url, broker_port)  
  File "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\site-packages  \paho\mqtt\client.py", line 914, in connect  
    return self.reconnect()  
  File "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\site-packages  \paho\mqtt\client.py", line 1044, in reconnect  
    sock = self._create_socket_connection()  
  File "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\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 "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\socket.py", line   824, in create_connection  
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):  
  File "C:\Users\TorbenIT\AppData\Local\Programs\Python\Python310\lib\socket.py", line   955, in getaddrinfo  
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):  
socket.gaierror: [Errno 11001] getaddrinfo failed  
hardillb
  • 54,545
  • 11
  • 67
  • 105
Tobi S
  • 145
  • 8
  • does this [help](https://stackoverflow.com/questions/7334199/getaddrinfo-failed-what-does-that-mean) – Kofi Jan 11 '22 at 13:34

2 Answers2

1

The service does not exist at mqtt.eclipse.org. It was either used only as an example or the service is no longer available.

You should use another MQTT instance, maybe run a local instance instead.

enter image description here

  • 1
    Google "public mqtt broker" and use one that actually works. You get what you paid for. – Gambit Support Jan 11 '22 at 15:17
  • Alright, but I also tried it with my own mqtt broker, which I set up and put in my room next to me, so I wrote its IP into the broker_url and got the same error. – Tobi S Jan 11 '22 at 16:26
  • Unlikely, as the error is specifically about resolving the name to the IP address, if you entered a IP then there will be no resolve step. Ask a new question with the new code and error message. Include details of how you configured the broker. – hardillb Jan 12 '22 at 08:23
0

I'm trying to follow a demo (this old one: http://www.steves-internet-guide.com/into-mqtt-python-client/), which suggests to use the same public broker. It doesn't work.

Moving from mqtt.eclipse.org to broker.hivemq.com works for me today.

  • If you have a new question, please ask it by clicking the [Ask Question](https://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/late-answers/34033176) –  Mar 20 '23 at 17:36