pycares
pycares copied to clipboard
Wrong answer for DNS queries after an internet outage
My application works in a Windows environment where internet dropouts may happen. If the app makes a DNS query at such a moment, it can't get the answer even when the connection has been re-established.
Let's look at an example - I've taken the code from the repository __main__.py
file and have changed only two last lines to make a cycle:
while True:
channel.query(hostname, query_type, cb)
wait_channel(channel)
time.sleep(1)
For imitations of a network outage, I apply the following command (Windows):
netsh wlan add filter permission=block ssid="<Wi-Fi ssid>" networktype=infrastructure
After running the changed __main__.py
I get: Error: (11) Could not contact DNS servers
. Even after the network establishment (or filter removal via netsh wlan delete filter <...>
) during the working script, I still receive the same error message with no successful answer. Only a full script re-run helps in this situation.
I'm not sure whether this issue lies inside c-ares
or not, as I wasn't able to make it run on Windows, but presumably you may know better.