Home Assistant Timeouterror connecting to Traccar

Thomas a year ago

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

Anton Tananaev a year ago

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

Thomas a year 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 Tananaev a year ago

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

Thomas a year 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 Tananaev a year ago

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

Thomas a year 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 Tananaev a year ago

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

Thomas a year ago

As in i switched from H2 database to MySQL

Anton Tananaev a year ago

Don't have any other ideas.

ildar 3 months ago

Starting from ~June 2025, I cannot use traccar with demo3 server, both mobile Traccar Manager app & web access do not work stable, reported it on github.
And also HomeAssistant stopped working with Traccar, and I even cannot add a new connection, reported here: https://github.com/home-assistant/core/issues/148852.
Since a person who is responsible for Traccar integration with HomeAssistant stopped maintaining it, there is a very little of hope that the issue will be solved from HA side, not to mention that I cannot use Traccar even via web interface...

Anton Tananaev 3 months ago

What is the problem with demo3? This is the first time I hear about it.

ildar 3 months ago

https://github.com/traccar/traccar-client/issues/20
https://github.com/traccar/traccar-client/issues/24
And also reported an issue like "device is online - but very old fix time" (https://github.com/traccar/traccar-client/issues/20#issuecomment-3090766791), and a contrary case (https://github.com/traccar/traccar-client/issues/20#issuecomment-3079581252).
I literally cannot use ALL my 7 devices since May 2025 (web interface, Traccar manager app), not to mention that HomeAssistant issue (which could be caused by HomeAssistant).

Anton Tananaev 3 months ago

I don't see how it's related to demo3. You seem to have a problem with the client app, not a server.

ildar 3 months ago

I don't see how it's related to demo3

May be, I am not insisting that this is caused by demo3 server exactly, my phrase "I cannot use traccar with demo3 server" was not about "issue is caused by a particular server". It was just a confirmation that HomeAssistant cannot connect to a demo server as well.