Home Assistant Timeouterror connecting to Traccar

Thomas12 days ago

Failed setup, will retry: Error while updating device data: Timeouterror connecting to Traccar

Anton Tananaev12 days ago

You should probably provide some more context and details. And I'm assuming you already checked the connection between the two?

Thomas11 days ago

I have observed that Traccar Server integration works for a few hours then begins to fail.

Logger: homeassistant.components.traccar_server
Source: components/traccar_server/coordinator.py:235
integration: Traccar Server (documentation, issues)
First occurred: 1:26:07 PM (2 occurrences)
Last logged: 1:57:32 PM
Error while subscribing to Traccar: Could not communicate with Traccar - 405, message='Invalid response status', url='https://mytraccarserverhere/api/socket'


Logger: homeassistant
Source: components/traccar_server/coordinator.py:237
First occurred: 5:46:00 PM (1 occurrences)
Last logged: 5:46:00 PM
Error doing job: Task exception was never retrieved (None)

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/aiohttp/client.py", line 703, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        req, traces=traces, timeout=real_timeout
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 548, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1056, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 1351, in _create_direct_connection
    hosts = await self._resolve_host(host, port, traces=traces)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/connector.py", line 970, in _resolve_host
    await future
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:
...
  File "/usr/local/lib/python3.13/site-packages/aiohttp/formdata.py", line 29, in __init__
    self._writer = multipart.MultipartWriter("form-data")
                   ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/multipart.py", line 809, in __init__
    ctype = f"multipart/{subtype}; boundary={self._boundary_value}"
                                             ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/aiohttp/multipart.py", line 859, in _boundary_value
    if re.match(self._valid_tchar_regex, value):
       ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/re/__init__.py", line 167, in match
    return _compile(pattern, flags).match(string)
           ~~~~~~~~^^^^^^^^^^^^^^^^
RecursionError: maximum recursion depth exceeded

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/traccar_server/coordinator.py", line 231, in subscribe
    await self.client.subscribe(self.handle_subscription_data)
  File "/usr/local/lib/python3.13/site-packages/pytraccar/client.py", line 237, in subscribe
    raise TraccarException(f"Unexpected error - {exception}") from exception
pytraccar.exceptions.TraccarException: Unexpected error - maximum recursion depth exceeded

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/traccar_server/coordinator.py", line 238, in subscribe
    await self.subscribe()
  File "/usr/src/homeassistant/homeassistant/components/traccar_server/coordinator.py", line 238, in subscribe
    await self.subscribe()
  File "/usr/src/homeassistant/homeassistant/components/traccar_server/coordinator.py", line 238, in subscribe
    await self.subscribe()
  [Previous line repeated 982 more times]
  File "/usr/src/homeassistant/homeassistant/components/traccar_server/coordinator.py", line 237, in subscribe
    await asyncio.sleep(10)
  File "/usr/local/lib/python3.13/asyncio/tasks.py", line 714, in sleep
    h = loop.call_later(delay,
                        futures._set_result_unless_cancelled,
                        future, result)
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 794, in call_later
    timer = self.call_at(self.time() + delay, callback, *args,
                         context=context)
  File "/usr/local/lib/python3.13/asyncio/base_events.py", line 811, in call_at
    timer = events.TimerHandle(when, callback, args, self, context)
  File "/usr/local/lib/python3.13/asyncio/events.py", line 114, in __init__
    super().__init__(callback, args, loop, context)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/events.py", line 45, in __init__
    if self._loop.get_debug():
       ~~~~~~~~~~~~~~~~~~~~^^
RecursionError: maximum recursion depth exceeded
Anton Tananaev11 days ago

Are you sure it's not caused by your proxy?

Thomas11 days ago

Its a possibility, it works for a few hours then stops working so where in my proxy might i be looking at?
Using an apache reverse proxy for ssl

My config looks like this

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName [mytraccarserverhere]

    # Reverse Proxy to Traccar
    ProxyPreserveHost On
    ProxyPass / http://localhost:8082/
    ProxyPassReverse / http://localhost:8082/

    # WebSocket Proxy for Traccar
    ProxyPass "/api/socket" "ws://localhost:8082/api/socket"
    ProxyPassReverse "/api/socket" "ws://localhost:8082/api/socket"

    # Logs
    ErrorLog ${APACHE_LOG_DIR}/[mytraccarserverhere]-error.log
    CustomLog ${APACHE_LOG_DIR}/[mytraccarserverhere].log combined

    # SSL Configuration
    SSLCertificateFile /etc/letsencrypt/live/[mytraccarserverhere]/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/[mytraccarserverhere]/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
210.54.38.71 - - [28/Jan/2025:16:42:47 +1300] "DELETE /api/session HTTP/1.1" 204 320 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
210.54.38.71 - - [28/Jan/2025:16:42:57 +1300] "POST /api/session HTTP/1.1" 200 4067 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
210.54.38.71 - - [28/Jan/2025:16:42:57 +1300] "GET /api/socket HTTP/1.1" 405 384 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
210.54.38.71 - - [28/Jan/2025:16:42:57 +1300] "DELETE /api/session HTTP/1.1" 204 320 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
210.54.38.71 - - [28/Jan/2025:16:43:07 +1300] "POST /api/session HTTP/1.1" 200 4067 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
210.54.38.71 - - [28/Jan/2025:16:43:07 +1300] "GET /api/socket HTTP/1.1" 405 384 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
210.54.38.71 - - [28/Jan/2025:16:43:07 +1300] "DELETE /api/session HTTP/1.1" 204 320 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
210.54.38.71 - - [28/Jan/2025:16:43:17 +1300] "POST /api/session HTTP/1.1" 200 4068 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
210.54.38.71 - - [28/Jan/2025:16:43:17 +1300] "GET /api/socket HTTP/1.1" 405 384 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
210.54.38.71 - - [28/Jan/2025:16:43:17 +1300] "DELETE /api/session HTTP/1.1" 204 320 "-" "HomeAssistant/2025.1.4 aiohttp/3.11.11 Python/3.13"
Anton Tananaev11 days ago

And you're using the latest official Traccar without any code changes?

Thomas11 days ago

The traccar server is on v6.5 and home assistant on the latest verison, no code changes, only some filtering and sql changes in traccar.xml

Anton Tananaev11 days ago

What do you mean by "sql changes in traccar.xml"?

Thomas11 days ago

As in i switched from H2 database to MySQL

Anton Tananaev11 days ago

Don't have any other ideas.