Tesla Connection Reset by Peer

For the last week, I have been unable to connect to Tesla. I am getting the below error. Any thoughts?

Log Details (ERROR)
Thu Jan 02 2020 11:59:40 GMT-0500 (Eastern Standard Time)
Error during setup of component tesla
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/aiohttp/connector.py”, line 936, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 981, in create_connection
ssl_handshake_timeout=ssl_handshake_timeout)
File “/usr/local/lib/python3.7/asyncio/base_events.py”, line 1009, in _create_connection_transport
await waiter
File “/usr/local/lib/python3.7/asyncio/selector_events.py”, line 860, in write
n = self._sock.send(data)
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/setup.py”, line 172, in _async_setup_component
hass, processed_config
File “/usr/src/homeassistant/homeassistant/components/tesla/init.py”, line 57, in async_setup
await controller.connect(test_login=False)
File “/usr/local/lib/python3.7/site-packages/teslajsonpy/controller.py”, line 72, in connect
cars = await self.get_vehicles()
File “/usr/local/lib/python3.7/site-packages/teslajsonpy/controller.py”, line 291, in get_vehicles
return (await self.__connection.get(“vehicles”))[“response”]
File “/usr/local/lib/python3.7/site-packages/teslajsonpy/connection.py”, line 87, in get
return await self.post(command, “get”, None)
File “/usr/local/lib/python3.7/site-packages/teslajsonpy/connection.py”, line 93, in post
auth = await self.__open("/oauth/token", “post”, data=self.oauth)
File “/usr/local/lib/python3.7/site-packages/teslajsonpy/connection.py”, line 130, in __open
url, headers=headers, data=data
File “/usr/local/lib/python3.7/site-packages/aiohttp/client.py”, line 483, in _request
timeout=real_timeout
File “/usr/local/lib/python3.7/site-packages/aiohttp/connector.py”, line 523, in connect
proto = await self._create_connection(req, traces, timeout)
File “/usr/local/lib/python3.7/site-packages/aiohttp/connector.py”, line 859, in _create_connection
req, traces, timeout)
File “/usr/local/lib/python3.7/site-packages/aiohttp/connector.py”, line 1004, in _create_direct_connection
raise last_exc
File “/usr/local/lib/python3.7/site-packages/aiohttp/connector.py”, line 986, in _create_direct_connection
req=req, client_error=client_error)
File “/usr/local/lib/python3.7/site-packages/aiohttp/connector.py”, line 943, in _wrap_create_connection
raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host owner-api.teslamotors.com:443 ssl:None [Connection reset by peer]

I have this issue too…

same issue

Same here. I see the URL is opened on port 443, but it also states ssl:None, which is contradictory. Maybe we have https issues?

+1

randomly at some reboots I get this error, after removing integration and adding again it works.

Edit: The integration returns unavailable battery %

2020-04-30 10:59:23 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry ************(emailaddress)  for tesla
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 989, in create_connection
    ssl_handshake_timeout=ssl_handshake_timeout)
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 1017, in _create_connection_transport
    await waiter
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 870, in write
    n = self._sock.send(data)
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 216, in async_setup
    hass, self
  File "/usr/src/homeassistant/homeassistant/components/tesla/__init__.py", line 141, in async_setup_entry
    CONF_WAKE_ON_START, DEFAULT_WAKE_ON_START
  File "/usr/local/lib/python3.7/site-packages/teslajsonpy/controller.py", line 264, in connect
    cars = await self.get_vehicles()
  File "/usr/local/lib/python3.7/site-packages/teslajsonpy/controller.py", line 362, in get_vehicles
    return (await self.__connection.get("vehicles"))["response"]
  File "/usr/local/lib/python3.7/site-packages/teslajsonpy/connection.py", line 98, in get
    return await self.post(command, "get", None)
  File "/usr/local/lib/python3.7/site-packages/teslajsonpy/connection.py", line 115, in post
    f"{self.api}{command}", method=method, headers=self.head, data=data
  File "/usr/local/lib/python3.7/site-packages/teslajsonpy/connection.py", line 151, in __open
    url, headers=headers, data=data
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 483, in _request
    timeout=real_timeout
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 859, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 986, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host owner-api.teslamotors.com:443 ssl:None [Connection reset by peer]

It’s possibly a SSL error. I suspect there’s something odd going on with the ciphers on all the systems having this error but can’t prove it (this is based on googling the general error and finding various threads talking about updating ciphers, etc.). However, the reference to ssl:None has a special meaning in aiohttp. It doesn’t mean SSL is disabled, it means there’s no special SSL context being passed through. So in other words, we’re using the default certificates that ship with the system.

I put in a PR to add a verify_ssl option that you can try setting to False. No idea if it’ll help but thought it might be worth trying.

Cross posting to this topic as well.

There is definitely something going on with the integration. Over the weekend, I opened up issue# 44777 (https://github.com/home-assistant/core/issues/44777) in the hopes that the responsible developers will look into it. Short story is this – the integration works fine until someone opens their Tesla Mobile app to interact with their car. As soon as the mobile app is opened, the HomeAssistant Tesla integration gets into an unauthenticated state and doesn’t recover.