blog-eivindgl-com / netatmo-pyportal-display

CircuitPython project to use PyPortal as display for a Netatmo weather station
MIT License
1 stars 0 forks source link

TimeoutError when reloading local time #9

Open eloekset opened 1 year ago

eloekset commented 1 year ago

Error after running through the night. Timeout when calling API to update local time:

20230105_072339.jpg

eloekset commented 1 year ago

Application insights on the on-prem Netatmo proxy tracks requests against http://io.adafruit.com/api/.../time/strftime for some reason. This happens twice a minute (on every loop) once it starts. And all requests get http 404 not found.

It's surprising to see this information logged in Application Insights, because there's no logging on the PyPortal device. Application Insights is connected to the on-prem ASP.NET Core web api that proxies the Netatmo API. Requests from PyPortal to http://io.adafruit.com/api should not go through the on-proxy application at all. So how is this possible? If it happens, it's not very surprising that the response is http 404.

image

This is a diagram showing the unexpected flow when PyPortal.get_local_time() runs on second and later iterations: image

eloekset commented 1 year ago

This graph shows how the traffic suddenly switches from the expected http://<local-ip>:8080/api/Display to http://io.adafruit.com/api/.../time/strftime endpoint. image

eloekset commented 1 year ago

The last request that made PyPortal raise TimeoutError took only 257 micro seconds: image

That was after 681 failing requests during around 10 minutes: image

eloekset commented 1 year ago

I just realized that this error has a different message than the first one when the issue was opened. But the error type is the same.

processed-4951b660-0545-4bd9-8307-fd4fb75d49fa_1tlfoQzc

eloekset commented 1 year ago

See if the error goes away if the .NET proxy application implements a handler for the route that PyPortal uses to refresh local time: image

eloekset commented 1 year ago

The display has been running for a while now, and Application Insights proves that it's the on-prem proxy API that is called instead of http://io.adafruit.com/. This is very strange behavior. image image

eloekset commented 1 year ago

The issue doesn't occur when PyPortal is running in my apartment. I guess the router was causing the issue. image

eloekset commented 1 year ago

The problem is back. And this time it ran for more than 24 hours before it crashed. Application Insights says there was no requests for strftime when PyPortal crashed, so that means it was the official API at io.adafruit.com that was called when TimeoutError occurred. image

eloekset commented 1 year ago

And now the routing issue happened on my own LAN too: image