It's 🐍CircuitPython Monday🐍 at Adafruit! Use the code ADATY to get 20% off CircuitPython and 15% off items storewide!
0

Temporary Failure in Name Resolution on Raspberry Pi
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Temporary Failure in Name Resolution on Raspberry Pi

by Tom_Henry on Sat Oct 23, 2021 11:48 pm

I am running a very simple CircuitPython program that posts sensor values of temperature, pressure, and humidity to my Adafruit io account. I am using a Raspberry Pi connected to our home WiFi. The program runs fine for a few hours and then eventually crashes with an error called “temporary failure in name resolution”.

I have run similar CircuitPython programs on an Adafruit Feather RP2040 with an AirLift FeatherWing WiFi ESP32 and the Metro ESP32-S2. Both of these boards continue running for days and days with no errors.

I have been trying to figure out how to fix my Raspberry Pi that is running CircuitPython and am looking for code examples to make an exception when a temporary failure in name resolution occurs and then have the program continue running.

I would appreciate any code suggestions or links to websites that have a fairly simple solution. I am just an intermediate Python coder.

Thanks,

Tom Henry

Tom_Henry
 
Posts: 128
Joined: Wed Aug 26, 2020 8:19 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by brubell on Mon Oct 25, 2021 9:50 am

Could you please post the full error output and the full code?

brubell
 
Posts: 1561
Joined: Fri Jul 17, 2015 10:33 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by Tom_Henry on Tue Oct 26, 2021 10:18 am

Tuesday, October 26th

Here you go.

I also added what is printed out each 60 seconds before the error info.


Tom Henry
Attachments
Name Resolution error.txt
(4.68 KiB) Downloaded 6 times
pi.sensors.10.25.py
(6.94 KiB) Downloaded 3 times

Tom_Henry
 
Posts: 128
Joined: Wed Aug 26, 2020 8:19 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by Tom_Henry on Tue Oct 26, 2021 12:18 pm

Just realized I posted my Adafruit io key. I have just changed my key to an new one.

Tom Henry

Tom_Henry
 
Posts: 128
Joined: Wed Aug 26, 2020 8:19 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by Tom_Henry on Wed Nov 03, 2021 11:46 pm

I am still waiting for an answer to my problem with the name resolution error.

Thank you,

Tom Henry

Tom_Henry
 
Posts: 128
Joined: Wed Aug 26, 2020 8:19 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by brubell on Fri Nov 05, 2021 10:24 am

Could you please try upgrading the urllib3 and requests packages?
Code: Select all | TOGGLE FULL SIZE
pip install urllib3 --upgrade
pip install requests --upgrade

brubell
 
Posts: 1561
Joined: Fri Jul 17, 2015 10:33 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by Tom_Henry on Sat Nov 06, 2021 12:53 pm

Saturday morning

I did the upgrades. See attached file called upgrades.txt.

Then I ran the program called pi.sensor.10.25.py formerly sent to you.

The program ran for 4 hours before crashing. See attached copy of my Dashboard showing that.

Finally I have attached the complete error print out. I noticed that in addition to the name resolution, I am get a connection error.

So, what do you think?

Tom Henry
Attachments
upgrades.txt
(2.16 KiB) Downloaded 1 time
Tom's Dashboard.png
Tom's Dashboard.png (173.63 KiB) Viewed 202 times
Name.Resolution.Error.txt
(4.89 KiB) Downloaded 1 time

Tom_Henry
 
Posts: 128
Joined: Wed Aug 26, 2020 8:19 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by Tom_Henry on Wed Nov 10, 2021 12:36 am

Hoping you have another idea for me to fix my code.

Thanks,

Tom Henry

Tom_Henry
 
Posts: 128
Joined: Wed Aug 26, 2020 8:19 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by cj8scrambler on Thu Nov 11, 2021 2:15 pm

I see these intermittent networking issues on Raspberry Pi as well. I think the problem is that you're not catching the except correctly on line 213. You're catching ConnectionError, but the exception being thrown is requests.exceptions.ConnectionError. If you want to catch all failures, just do something like:
Code: Select all | TOGGLE FULL SIZE
try:
    aio.send(time_feed.key, str(todays_time))
    #[rest of sends]
except:
    print("An Error has occurred.")
    #[rest of error handling]

cj8scrambler
 
Posts: 5
Joined: Wed Jun 29, 2016 4:47 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by Tom_Henry on Fri Nov 12, 2021 1:13 pm

I think I am getting closer to fixing my problem.

I ran the attached program with changes per your suggestions. It ran for 15 hours with no errors.

I attached a copy of a partial print out of the data and full copy of the error information.

I am hoping that you can help me tweak something to catch any and all errors.

Thanks,

Tom Henry
Attachments
Error_file.txt
(5.17 KiB) Downloaded 4 times
pi.sensors.11.11.py
(6.83 KiB) Downloaded 4 times

Tom_Henry
 
Posts: 128
Joined: Wed Aug 26, 2020 8:19 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by cj8scrambler on Fri Nov 12, 2021 2:48 pm

The exception handling worked. The problem is that you are calling an undefined module in the exception handler. The error messages tell you exactly where to look:

Code: Select all | TOGGLE FULL SIZE
[Traceback (most recent call last):
  File "/home/pi/pi.sensors.11.11.py", line 223, in <module>
    io.connect
NameError: name 'io' is not defined

cj8scrambler
 
Posts: 5
Joined: Wed Jun 29, 2016 4:47 pm

Re: Temporary Failure in Name Resolution on Raspberry Pi

by Tom_Henry on Mon Nov 15, 2021 1:33 pm

Looks like you helped me fix the problem.

The Raspberry Pi Zero W with attached sensors MS8607 and PMSA003I has been working now for 55 hours with no errors.

I will let it keep running and see what happens.

See attached modified last part of CircuitPython code and a copy of my Adafruit io Dashboard showing sensor readings.

Thanks for your patience in helping me.

Tom Henry
Attachments
Raspberry Pi Zero W.png
Raspberry Pi Zero W.png (173.18 KiB) Viewed 112 times
fix.errors.txt
(1.17 KiB) Downloaded 1 time

Tom_Henry
 
Posts: 128
Joined: Wed Aug 26, 2020 8:19 pm

Please be positive and constructive with your questions and comments.