Skip to content

Set of Tasks/Futures is empty. #389

@nirnaeth-arnoediad

Description

@nirnaeth-arnoediad

Trying to connect my mg4 through mgtt gateway but getting an error shown below.
Using ubuntu 24.04 (vm) to setup bridge.
App/Car Location is Turkey (tried different regions but app wont allow me to login/bind the vehicle via QR).
Using EU app (turkish version's account is not even recognized).
I suspect that vehicle list is empty so container crashes.

Here the logs:


mosquitto          | 1762033155: mosquitto version 2.0.22 starting
mosquitto          | 1762033155: Config loaded from /mosquitto/config/mosquitto.conf.
mosquitto          | 1762033155: Warning: File /mosquitto/config/passwd has world readable permissions. Future versions will refuse to load this file.
mosquitto          | To fix this, use `chmod 0700 /mosquitto/config/passwd`.
mosquitto          | 1762033155: Opening ipv4 listen socket on port 1883.
mosquitto          | 1762033155: Opening ipv6 listen socket on port 1883.
mosquitto          | 1762033155: mosquitto version 2.0.22 running
mosquitto          | 1762033158: New connection from 127.0.0.1:60006 on port 1883.
mosquitto          | 1762033158: New client connected from 127.0.0.1:60006 as saic-python-mqtt-gateway (p2, c1, k60, u'saicuser').
saic-mqtt-gateway  | 2025-11-01 21:39:17,782 [INFO]: Logging in to SAIC API - handlers.relogin
saic-mqtt-gateway  | 2025-11-01 21:39:17,843 [DEBUG]: connect_tcp.started host='gateway-mg-eu.soimt.com' port=443 local_address=None timeout=10.0 socket_options=None - httpcore.connection
saic-mqtt-gateway  | 2025-11-01 21:39:18,026 [DEBUG]: connect_tcp.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7220d3b6e3c0> - httpcore.connection
saic-mqtt-gateway  | 2025-11-01 21:39:18,026 [DEBUG]: start_tls.started ssl_context=<ssl.SSLContext object at 0x7220d36b1ed0> server_hostname='gateway-mg-eu.soimt.com' timeout=10.0 - httpcore.connection
saic-mqtt-gateway  | 2025-11-01 21:39:18,083 [DEBUG]: start_tls.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7220d3dbd3d0> - httpcore.connection
saic-mqtt-gateway  | 2025-11-01 21:39:18,084 [DEBUG]: send_request_headers.started request=<Request [b'POST']> - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,085 [DEBUG]: send_request_headers.complete - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,085 [DEBUG]: send_request_body.started request=<Request [b'POST']> - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,086 [DEBUG]: send_request_body.complete - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,086 [DEBUG]: receive_response_headers.started request=<Request [b'POST']> - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,252 [DEBUG]: receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Sat, 01 Nov 2025 21:39:18 GMT'), (b'Content-Type', b'application/x-www-form-urlencoded'), (b'Content-Length', b'4032'), (b'Connection', b'keep-alive'), (b'Cache-Control', b'no-store'), (b'Pragma', b'no-cache'), (b'X-Content-Type-Options', b'nosniff'), (b'X-XSS-Protection', b'1; mode=block'), (b'X-Frame-Options', b'DENY'), (b'APP-CONTENT-ENCRYPTED', b'1'), (b'ORIGINAL-CONTENT-TYPE', b'application/x-www-form-urlencoded'), (b'APP-SEND-DATE', b'1762033158231'), (b'APP-VERIFICATION-STRING', b'c0b4e03a09083c5a3a0e38545da74b7a1ccd0fd1912e26423e9ff24c6740c78c')]) - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,254 [DEBUG]: receive_response_body.started request=<Request [b'POST']> - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,256 [DEBUG]: receive_response_body.complete - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,256 [DEBUG]: response_closed.started - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,257 [DEBUG]: response_closed.complete - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,261 [INFO]: Logged in as XXXXXXX  - handlers.relogin
saic-mqtt-gateway  | 2025-11-01 21:39:18,261 [INFO]: Fetching vehicle list - mqtt_gateway
saic-mqtt-gateway  | 2025-11-01 21:39:18,264 [DEBUG]: send_request_headers.started request=<Request [b'GET']> - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,266 [DEBUG]: send_request_headers.complete - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,266 [DEBUG]: send_request_body.started request=<Request [b'GET']> - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,267 [DEBUG]: send_request_body.complete - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,267 [DEBUG]: receive_response_headers.started request=<Request [b'GET']> - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,379 [DEBUG]: receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Date', b'Sat, 01 Nov 2025 21:39:18 GMT'), (b'Content-Type', b'application/json;charset=utf-8'), (b'Content-Length', b'128'), (b'Connection', b'keep-alive'), (b'APP-CONTENT-ENCRYPTED', b'1'), (b'ORIGINAL-CONTENT-TYPE', b'application/json'), (b'APP-SEND-DATE', b'1762033158358'), (b'APP-VERIFICATION-STRING', b'c78fb907b797a6adc13ab1e761f6bad9fbad17fe51a0612e450c8b49153ce2a0')]) - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,379 [DEBUG]: receive_response_body.started request=<Request [b'GET']> - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,380 [DEBUG]: receive_response_body.complete - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,381 [DEBUG]: response_closed.started - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,381 [DEBUG]: response_closed.complete - httpcore.http11
saic-mqtt-gateway  | 2025-11-01 21:39:18,385 [INFO]: Adding job tentatively -- it will be properly scheduled when the scheduler starts - apscheduler.scheduler
saic-mqtt-gateway  | 2025-11-01 21:39:18,385 [INFO]: Connecting to MQTT Broker - mqtt_gateway
saic-mqtt-gateway  | 2025-11-01 21:39:18,392 [INFO]: Connected to MQTT broker - publisher.mqtt_publisher
saic-mqtt-gateway  | 2025-11-01 21:39:18,392 [INFO]: Starting scheduler - mqtt_gateway
saic-mqtt-gateway  | 2025-11-01 21:39:18,394 [INFO]: Added job "Check for new messages" to job store "default" - apscheduler.scheduler
saic-mqtt-gateway  | 2025-11-01 21:39:18,395 [INFO]: Scheduler started - apscheduler.scheduler
saic-mqtt-gateway  | 2025-11-01 21:39:18,395 [INFO]: Entering main loop - mqtt_gateway
saic-mqtt-gateway  | 2025-11-01 21:39:18,395 [DEBUG]: Looking for jobs to run - apscheduler.scheduler
saic-mqtt-gateway  | 2025-11-01 21:39:18,396 [DEBUG]: Next wakeup is due at 2025-11-01 21:40:18.384925+00:00 (in 59.988884 seconds) - apscheduler.scheduler
saic-mqtt-gateway  | Traceback (most recent call last):
saic-mqtt-gateway  |   File "/usr/src/app/./main.py", line 24, in <module>
saic-mqtt-gateway  |     asyncio.run(mqtt_gateway.run(), debug=debug_log_enabled())
saic-mqtt-gateway  |   File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run
saic-mqtt-gateway  |     return runner.run(main)
saic-mqtt-gateway  |            ^^^^^^^^^^^^^^^^
saic-mqtt-gateway  |   File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
saic-mqtt-gateway  |     return self._loop.run_until_complete(task)
saic-mqtt-gateway  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
saic-mqtt-gateway  |   File "/usr/local/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
saic-mqtt-gateway  |     return future.result()
saic-mqtt-gateway  |            ^^^^^^^^^^^^^^^
saic-mqtt-gateway  |   File "/usr/src/app/mqtt_gateway.py", line 106, in run
saic-mqtt-gateway  |     await self.__main_loop()
saic-mqtt-gateway  |   File "/usr/src/app/mqtt_gateway.py", line 246, in __main_loop
saic-mqtt-gateway  |     await self.__shutdown_handler(tasks)
saic-mqtt-gateway  |   File "/usr/src/app/mqtt_gateway.py", line 251, in __shutdown_handler
saic-mqtt-gateway  |     done, pending = await asyncio.wait(
saic-mqtt-gateway  |                     ^^^^^^^^^^^^^^^^^^^
saic-mqtt-gateway  |   File "/usr/local/lib/python3.12/asyncio/tasks.py", line 454, in wait
saic-mqtt-gateway  |     raise ValueError('Set of Tasks/Futures is empty.')
saic-mqtt-gateway  | ValueError: Set of Tasks/Futures is empty.
mosquitto          | 1762033158: Client saic-python-mqtt-gateway closed its connection.

here my env:

MQTT_BROKER_URI=tcp://127.0.0.1:1883
MQTT_USERNAME=saicuser
MQTT_PASSWORD=saicpass
SAIC_USERNAME=xxxxxxx
SAIC_PWD=xxxxxx
ABRP_USER_TOKEN=LSxxxxxxxx=82xxxxxxxxxx
LOG_LEVEL=DEBUG

and docker-compose.yml:

version: "3.9"

services:
  mosquitto:
    image: eclipse-mosquitto:2.0.22
    container_name: mosquitto
    network_mode: host
    restart: "no"
    volumes:
      - ./mosquitto/config:/mosquitto/config
      - ./mosquitto/data:/mosquitto/data
      - ./mosquitto/log:/mosquitto/log
    environment:
      - MQTT_USERNAME=${MQTT_USERNAME}
      - MQTT_PASSWORD=${MQTT_PASSWORD}
      #Log Level
      - LOG_LEVEL=${LOG_LEVEL}
  saic-mqtt-gateway:
    image: "saicismartapi/saic-python-mqtt-gateway:latest"
    build:
      context: .
    container_name: saic-mqtt-gateway
    network_mode: host
    depends_on:
      - mosquitto
    environment:
      # MQTT config
      - MQTT_URI=${MQTT_BROKER_URI}
      - MQTT_USER=${MQTT_USERNAME}
      - MQTT_PASSWORD=${MQTT_PASSWORD}

      # SAIC API credentials
      - SAIC_USER=${SAIC_USERNAME}
      - SAIC_PASSWORD=${SAIC_PWD}

      # ABRP integration
      - ABRP_USER_TOKEN=${ABRP_USER_TOKEN}

      #Log Level
      - LOG_LEVEL=${LOG_LEVEL}
    volumes:
      - ./charging-stations.json:/usr/src/app/config/charging-stations.json:ro
    restart: "no"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions