arraylabs / pymyq

Python wrapper for MyQ API
MIT License
112 stars 42 forks source link

DEFAULT_USER_AGENT causes immediate Connection Reset #41

Closed zachreizner closed 3 years ago

zachreizner commented 4 years ago

I recently updated to the latest home-assistant 0.111 in order to use 2.0.3 of this library in order to fix the myq integration, but I was still getting this in my logs:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 217, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/myq/__init__.py", line 36, in async_setup_entry
    myq = await pymyq.login(conf[CONF_USERNAME], conf[CONF_PASSWORD], websession)
  File "/usr/local/lib/python3.7/site-packages/pymyq/api.py", line 172, in login
    await api.authenticate(username, password)
  File "/usr/local/lib/python3.7/site-packages/pymyq/api.py", line 121, in authenticate
    self._security_token = auth_resp["SecurityToken"]

Digging into this, I noticed too anomalies: 1) The number of retries being made was only two instead of five and 2) each connection attempt failed immediately with [Errno 104] Connection reset by peer.

After some experimentation using the example code from the README, I found that changing the DEFAULT_USER_AGENT in api.py to that of my desktop chrome browser fixed this issue.