Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example-mqtt.py Doesn't Work #9

Open
vatrat opened this issue Jul 6, 2017 · 5 comments
Open

example-mqtt.py Doesn't Work #9

vatrat opened this issue Jul 6, 2017 · 5 comments

Comments

@vatrat
Copy link

vatrat commented Jul 6, 2017

When I try to run the example-mqtt.py file, I get an error (Fedora 25, 64-bit).

$ python example-mqtt.py 
Traceback (most recent call last):
  File "example-mqtt.py", line 41, in <module>
    client.connect(MQTT_HOST, MQTT_PORT, 60)
  File "/usr/lib/python2.7/site-packages/paho/mqtt/client.py", line 760, in connect
    return self.reconnect()
  File "/usr/lib/python2.7/site-packages/paho/mqtt/client.py", line 887, in reconnect
    sock = socket.create_connection((self._host, self._port), source_address=(self._bind
_address, 0))                                                                          
  File "/usr/lib64/python2.7/socket.py", line 557, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known

example-minimal.py works as expected.

@toddmedema
Copy link
Owner

Interesting! Open to a PR to fix it - sounds like it should be fixable if the minimal example still works

@vatrat
Copy link
Author

vatrat commented Jul 7, 2017

I would open a PR, but I have no idea how to fix it.

@toddmedema
Copy link
Owner

Actually, looks like it might be a config or Python issue on your computer? https://stackoverflow.com/questions/23777121/why-am-i-getting-socket-gaierror-errno-2-from-python-httplib

@vatrat
Copy link
Author

vatrat commented Jul 7, 2017

That issue is a problem with the use of .local addresses instead of IP addresses. I think this issue has something to do with the MQTT_HOST variable. It's set to "jarvis". I don't think this is a valid hostname. That's probably why it doesn't work. I imagine you have to set up an MQTT server and put its address in that variable.

@toddmedema
Copy link
Owner

Ah yep! Let me know if setting up an MQTT server on your end and changing MQTT_HOST to point to it works for you - if it does, I'll update the docs to clarify that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants