Orange-OpenSource / its-client

This Intelligent Transportation Systems (ITS) MQTT client based on the JSon ETSI specification transcription provides a ready to connect project for the mobility (connected and autonomous vehicles, road side units, vulnerable road users,...). Let's connect your device or application to our Intelligent Transport Systems (ITS) platform!
MIT License
7 stars 8 forks source link

python/iqm: fix subscribing to neighbours, take 2 #196

Closed ymorin-orange closed 1 month ago

ymorin-orange commented 1 month ago

Bug fix:


How to test:

  1. start two MQTT brokers; the socket is considered "local", and 1235 is considered the "neighbour"; start an MQTT client on the local broker:
    $ cat >mosquitto.cfg <<_EOF_
    per_listener_settings true
    listener 0 /tmp/mqtt.sock
    allow_anonymous true
    _EOF_
    $ mosquitto -c mosquitto.cfg
    $ mosquitto -p 1234
    $ mosquitto_sub --unix /tmp/mqtt.sock -t '#' -F '%U %t %p'
  2. Install IoT3 Core SDK and its-iqm:
    1. start a docker container with python 3.11 (if you already have python 3.11 or later on your machine, you don't need the container):
      $ docker container run \
          --rm \
          -ti \
          --network host \
          -e http_proxy \
          -e https_proxy \
          -e no_proxy \
          --user $(id -u):$(id -u) \
          --mount type=bind,source=/tmp/mqtt.sock,destination=/tmp/mqtt.sock \
          --mount type=bind,source=$(pwd),destination=$(pwd) \
          --workdir $(pwd) \
          --entrypoint /bin/bash \
          python:3.11.9-slim-bookworm
    2. create and activate a venv to install into:
      (docker)$ python3 -m venv /tmp/iot3
      (docker)$ . /tmp/iot3/bin/activate
    3. install IoT3 Core SDK and its-iqm:
      (docker)$ pip3 --disable-pip-version-check \
          install \
          python/iot3/ \
          python/its-interqueuemanager/
  3. Start its-iqm with those configuration files:
    1. its.cfg:
      (docker)$ cat >its.cfg <<_EOF_
      [general]
      instance-id = test-iqm
      prefix = default
      suffix = v2x
      [local]
      socket-path = /tmp/mqtt.sock
      interqueue = interQueue
      [authority]
      type = file
      reload = 5
      path = neighbours.cfg
      _EOF_
    2. neighbours.cfg:
      (docker)$ cat >neighbours.cfg <<_EOF_
      [nghb]
      type = mqtt
      host = localhost
      port = 1234
      prefix = custom
      queue = interQueue
      suffix = v2x
      _EOF_
    3. start its-qm:
      (docker)$ its-iqm -c its.cfg
  4. Send a message to interQueue on the neighbour broker:
    $ mosquitto_pub -p 1234 -t custom/interQueue/v2x/cam/1/2/3/0 -m '"test-neighbour"'

Expected results:

  1. The message on the neighbour broker on interQueue is copied to outQueue on the local broker:
    1729861192.888402253 default/outQueue/v2x/cam/1/2/3/0 "test-neighbour"