jjvdgeer / weatherflow-udp

WeatherFlow Personal Weather Station driver for weewx, via UDP broadcast packets
GNU General Public License v3.0
12 stars 2 forks source link

Brief connectivity interruption causes Weewx exit #2

Open hikeonpast opened 2 years ago

hikeonpast commented 2 years ago

It appears that socket errors (such as would be experienced when rebooting an attached switch or briefly unplugging an Ethernet cable) cause weatherflow-udp to throw errors that aren't handled gracefully by WeeWx, resulting in an immediate process exit.

Given that WeeWx is typically operated in home environments, where internet/network connectivity can be intermittent, most folks don't run WeeWx under a supervisor that will restart it automatically, and most folks don't have process monitoring/alerting configured to catch an unexpected exit, gracefully handling connectivity issues seems highly desirable over a panic (silent) exit.

`Apr 25 13:28:36 pooppi weewx[450] INFO user.weatherflowudp: driver version is 1.13

Apr 25 13:28:36 pooppi weewx[450] ERROR weewx.engine: Import of driver failed: HTTPSConnectionPool(host='swd.weatherflow.com', port=443): Max retries exceeded with url: /swd/rest/stations?token= (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x75e361a8>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution') ) (<class 'requests.exceptions.ConnectionError'>)

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** Traceback (most recent call last):

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 169, in _new_conn

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** conn = connection.create_connection(

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 73, in create_connection

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** File "/usr/lib/python3.9/socket.py", line 953, in getaddrinfo

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** for res in _socket.getaddrinfo(host, port, family, type, proto, flags):

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** socket.gaierror: [Errno -3] Temporary failure in name resolution

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: ****

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** During handling of the above exception, another exception occurred:

Apr 25 13:28:36 pooppi weewx[450] CRITICAL weewx.engine: **** `

jjvdgeer commented 1 year ago

Sorry, I just recently became aware of this and another issue having been registered here. As far as I can see I wasn't notified for them. Maybe they ended up in the spam or maybe I should look into some settings...

Anyway, regarding the issue you reported. The URL noted is one that should only be called while starting. As the driver needs to check the environment, what devices you have and stuff like that, it really needs to do that in order to start up. After that's done it will fetch observations, but again, this should only happen in startup. After it has successfully started, it will go over to UDP and there should not be a problem. I think it is OK to require the internet to be functional when weewx starts up.