toddmedema / echo

For controlling local devices with the Amazon Echo
207 stars 84 forks source link

example-mqtt.py Doesn't Work #9

Open vatrat opened 7 years ago

vatrat commented 7 years ago

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 commented 7 years ago

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

vatrat commented 7 years ago

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

toddmedema commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 :)