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
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.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
- brubell
- Learn User Page
- Posts: 2010
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
Could you please post the full error output and the full code?
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
Tuesday, October 26th
Here you go.
I also added what is printed out each 60 seconds before the error info.
Tom Henry
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 10 times
-
- pi.sensors.10.25.py
- (6.94 KiB) Downloaded 6 times
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
Just realized I posted my Adafruit io key. I have just changed my key to an new one.
Tom Henry
Tom Henry
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
I am still waiting for an answer to my problem with the name resolution error.
Thank you,
Tom Henry
Thank you,
Tom Henry
- brubell
- Learn User Page
- Posts: 2010
- Joined: Fri Jul 17, 2015 10:33 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
Could you please try upgrading the urllib3 and requests packages?
Code: Select all
pip install urllib3 --upgrade
pip install requests --upgrade
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
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
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 4 times
-
- Tom's Dashboard.png (173.63 KiB) Viewed 554 times
-
- Name.Resolution.Error.txt
- (4.89 KiB) Downloaded 2 times
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
Hoping you have another idea for me to fix my code.
Thanks,
Tom Henry
Thanks,
Tom Henry
- cj8scrambler
- Posts: 7
- Joined: Wed Jun 29, 2016 4:47 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
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
try:
aio.send(time_feed.key, str(todays_time))
#[rest of sends]
except:
print("An Error has occurred.")
#[rest of error handling]
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
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
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 7 times
-
- pi.sensors.11.11.py
- (6.83 KiB) Downloaded 6 times
- cj8scrambler
- Posts: 7
- Joined: Wed Jun 29, 2016 4:47 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
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
[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
- Tom_Henry
- Posts: 350
- Joined: Wed Aug 26, 2020 8:19 pm
Re: Temporary Failure in Name Resolution on Raspberry Pi
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
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 (173.18 KiB) Viewed 464 times
-
- fix.errors.txt
- (1.17 KiB) Downloaded 2 times
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.