eclair4151/AlexaControlledSamsungTV

Server not starting

gledy2 opened this issue · 10 comments

Hi, completely new to pi and coding but bought one specifically to run this app. I hade issues on the first install, ended up loading again, same issue. I am sure from reading the other issues first it was a DNS issue, but not knowing what DNS really was and trying to change it unsuccessfully led to me having to install raspbian again. Another reload and another fault. The only difference I did during install was being unable to work out how to change values with vim as they came up in red and all I seemed to be able to do was delete them, so I ended up changing the tvconfig.py file in a text editor if this makes any difference? Here is my error message linked below, if it is a DNS issue a heads up on what to change where would be appreciated as I followed a few different guides before and ended up not getting any connection to wifi/Ethernet in the end, thanks, allan

pi@raspberrypi:~/AlexaControlledSamsungTV $ python3 alexasmartcli.py start
starting server...
Traceback (most recent call last):
File "alexasmartcli.py", line 181, in
mqtt_server.startServer(options.mute)
File "/home/pi/AlexaControlledSamsungTV/helpers/mqtt_server.py", line 247, in startServer
myMQTTClient.connect()
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/MQTTLib.py", line 408, in connect
return self._mqtt_core.connect(keepAliveIntervalSecond)
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 168, in connect
self.connect_async(keep_alive_sec, self._create_blocking_ack_callback(event))
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 179, in connect_async
rc = self._internal_async_client.connect(keep_alive_sec, ack_callback)
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/internal/clients.py", line 113, in connect
rc = self._paho_client.connect(host, port, keep_alive_sec)
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py", line 654, in connect
return self.reconnect()
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py", line 776, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File "/usr/lib/python3.5/socket.py", line 694, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/lib/python3.5/socket.py", line 733, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

Ah yes this looks like a DNS issue. Try this open up
/etc/resolv.conf
and see if you have some lines in there like
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx

if you do change them to
nameserver 8.8.8.8
nameserver 8.8.4.4

then restart your pi and try again. Let me know if you still have issues or if those lines arent in that file

if that doesnt work you can also try going into helpers/mqtt_server.py
and changeling line 240 from

myMQTTClient.configureEndpoint("afkx1f9takwol.iot.us-east-1.amazonaws.com", 8883)

to

myMQTTClient.configureEndpoint("52.1.238.55", 8883)

Thanks for getting back to me, I have just been learning vim as I couldn't edit the read only resolv.conf file with text editor, and learned how to write it with sudo. I have changed it and rebooted but no luck.
The resolv.conf file had only the following:
domain lan
nameserver 192.168.1.254
I did edit it to just the one line nameserver 8.8.8.8 but upon reboot it had changed back
Away to try the other option, will let you know, thanks

Hmm interesting. If that doesn't work here are some things you can try to change the DNS

https://askubuntu.com/questions/157154/how-do-i-include-lines-in-resolv-conf-that-wont-get-lost-on-reboot

Tried changing the mqtt_server.py file and no luck with that, will have a look at the next link, thanks for your help.

This is the error after changing the mqtt_server.py file if it helps, as it is different?

pi@raspberrypi:~/AlexaControlledSamsungTV $ python3 alexasmartcli.py start
starting server...
Traceback (most recent call last):
File "alexasmartcli.py", line 181, in
mqtt_server.startServer(options.mute)
File "/home/pi/AlexaControlledSamsungTV/helpers/mqtt_server.py", line 247, in startServer
myMQTTClient.connect()
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/MQTTLib.py", line 408, in connect
return self._mqtt_core.connect(keepAliveIntervalSecond)
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 168, in connect
self.connect_async(keep_alive_sec, self._create_blocking_ack_callback(event))
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/mqtt_core.py", line 179, in connect_async
rc = self._internal_async_client.connect(keep_alive_sec, ack_callback)
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/internal/clients.py", line 113, in connect
rc = self._paho_client.connect(host, port, keep_alive_sec)
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py", line 654, in connect
return self.reconnect()
File "/home/pi/.local/lib/python3.5/site-packages/AWSIoTPythonSDK/core/protocol/paho/client.py", line 803, in reconnect
ssl.match_hostname(self._ssl.getpeercert(), self._host)
File "/usr/lib/python3.5/ssl.py", line 305, in match_hostname
% (hostname, ', '.join(map(repr, dnsnames))))
ssl.CertificateError: hostname '52.1.238.55' doesn't match either of 'iot.us-east-1.amazonaws.com', '*.iot.us-east-1.amazonaws.com'

Oh yea I forgot that doesn’t work because of ssl. Yea try to figure out the dns stuff and let me know if you need help if you can’t get it

Sent with GitHawk

Thanks, its my first day of doing anything like this and tough reading for me! And a lot of looking up things! Still not quite following half of what I am doing but trying hard! Changed back the mqtt_server.py file, and reading up on the link you sent, but again my files seem to have different things in them and I am struggling what answer to try, as last time I followed tried to play with the dns it broke my connection, any help is hugely appreciated

Solved I think, by using this link, and changing the etc/dhcpcd.conf file. Server now running, away to test it out, fingers crossed! Thanks for your help, and hope this helps someone else...
https://pimylifeup.com/raspberry-pi-dns-settings/

Awesome! Glad you figured it out. I’ll add that link to the readme for others

Sent with GitHawk