Goose66 / myq-polyglotv2

Nodeserver for Chamberlain/LiftMaster MyQ Cloud Service for Polyglot v2
4 stars 1 forks source link

Temporary name resolution failure stops node #7

Closed xrxca closed 3 years ago

xrxca commented 3 years ago

I'm running polyglot on an rPi that is powered through POE, the problem I'm running into is that the switch it's connected to also powers the external gateway via POE, and the gateway is horribly slow coming up, As a result after a power failure, on startup my internal nodes are all quite happy, but this one fails as soon as it can't resolve the api hostname.

I've added a hack to my copy that does a retry/delay loop with socket.gethostbyname until either the loop counter runs out or it resolves the hostname which works for me, but I'd think it should be an option to retry for x amount of time if the failure is temporary like this..

2021-01-30 01:58:14,663 NodeServer polyinterface      WARNING  myqapi:_call_api: Network/server error in HTTP POST in _call_api(): HTTPSConnectionPool(host='api.myqdevice.com', port=443): Max retries exceeded with url: /api/v5/Login (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0xb5d6c4b0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
2021-01-30 01:58:14,664 NodeServer polyinterface      INFO     polyinterface:addNotice: Sending addnotice to Polyglot: {'key': 'login_error', 'value': 'There was an error connecting to the MyQ service. Please check the log files and correct the issue before restarting the nodeserver.'}
Goose66 commented 3 years ago

I can move the connection code to shortPoll, allowing it to retry until connection is successful. This, however, delays the initial connection until the shortPoll is done, which depending on what shortPoll is set to, could be 30 seconds or more. This tends to throw people into a tizzy.

Goose66 commented 3 years ago

A little late, but in the latest version of MyQ v2.2.15, the initial connection is done in the first longpoll (about 60 seconds after starting nodeserver), and it will retry every longpoll (every 60 seconds) to reestablish the connection. This should fix your issue.

xrxca commented 3 years ago

Finally got around to updating this node, and this does solve the issue I was having Thanks.