Skip to content

AWS IoT endpoints not resolved by many default router DNS providers - "Name or service not known" #192

@eclair4151

Description

@eclair4151

I have a service/script which allows people to control their TV using Alexa.
https://github.com/eclair4151/AlexaControlledSamsungTV

It uses this lib to connect over MQTT, and one issue many users get is the following error:

eclair4151/AlexaControlledSamsungTV#21
eclair4151/AlexaControlledSamsungTV#11
eclair4151/AlexaControlledSamsungTV#6
eclair4151/AlexaControlledSamsungTV#4

It can also be seen in previous issues of this lib here, which were closed for inactivity:
#101
#133
#27

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

Every single case of this issue is related to the fact their default DNS cant resolve my endpoint and fails to connect. In every case of this I see, getting the user to manually set their DNS on the machine to 8.8.8.8, 8.8.4.4 fixes the issue immediately.

The problem is I cant be asking all my users to change their DNS settings to use my software. I can't for the life of me figure out why this is an issue or how to fix it.

This is how the script is connecting which was taken directly from an example here

  myMQTTClient = AWSIoTMQTTClient(clientid)
    myMQTTClient.configureEndpoint("afkx1f9takwol.iot.us-east-1.amazonaws.com", 8883)
    myMQTTClient.configureCredentials(".auth/root.pem", ".auth/private.pem.key", ".auth/certificate.pem.crt")
    myMQTTClient.configureOfflinePublishQueueing(-1)  # Infinite offline Publish queueing
    myMQTTClient.configureDrainingFrequency(2)  # Draining: 2 Hz
    myMQTTClient.configureConnectDisconnectTimeout(10)  # 10 sec
    myMQTTClient.configureMQTTOperationTimeout(5)  # 5 sec
    myMQTTClient.connect()

Do you have any thoughts or suggestions on how to solve this?

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions