python/iqm: allow connecting via TCP, TLS, websockets#476
Merged
ymorin-orange merged 9 commits intoOrange-OpenSource:masterfrom Dec 10, 2025
Merged
python/iqm: allow connecting via TCP, TLS, websockets#476ymorin-orange merged 9 commits intoOrange-OpenSource:masterfrom
ymorin-orange merged 9 commits intoOrange-OpenSource:masterfrom
Conversation
…ker" The rationale behind 9b2c91c (python/iqm: use only UNIX socket to connect to local MQTT broker) has proven to become wrong since then: now that we can spawn multiple IQMs to share the load, it will start to make sense to have the IQMs running on different machines, and those may no longer be co-located on the same machine as the broker. Re-instate the possibility to connect to the local broker via TCP; still keep the UNIX socket for simpler setups, or for machines beefy enough to host multiple IQMs. This reverts commit 9b2c91c. Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Either host or socket-path is mandatory, so they should not have a default value (not even None). The port is made optional: the default MQTT port, 1883, is used as a default port. Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Iterating over the object yields all sections, even the "DEFAULT" section, which we ignore; we can however request the list of sections, which does not include the "DEFAULT" section, which is a bit simpler. Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
configparser.ConfigParser() only knows about strings, and does not handle anything else, especialy not None of bool. However, we do use None in a few places, so we convert the ConfigParser() to a dict before we use it everywhere. This means that we no longer have access to the ConfigParser.getbool(). Add a helper that allows easily converting a string-with-a-boolean into an actual boolean. Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
If the tls key is not provided, we end up with None, which makes for automatic TLS setup, which is exactly what we want. But if the tls key *is* provided, it is a string, not a boolean, as it comes from a configparser.ConfigParser(), which only handles strings; when converted to a dict(), there is no type conversion, so we still get a string. A non-empty string always tests True, whatever its content. So the string "False" tests as True, so we end up always using TLS, even when explicitly instructed not to. Fix that by using the newly introduced helper, that converts a boolean-in-a-string into a bool(). Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
b9fefa7 to
1437321
Compare
nbuffon
approved these changes
Dec 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Close #475
Test
How to test
Note: in the following:
$are to be executed on your machine, as a non-root user;(docker)$are to be executed in the Docker container;(docker)🐍 $are to be executed in the Docker container, in the python venv.$ mosquitto_sub \ -h test.mosquitto.org -p 8886 \ --tls-version tlsv1.3 --capath /etc/ssl/certs/ \ -i SUyX8BNsbCr633okVYVwVPIX \ -t 'default/+/v2x/#' \ -V 5 \ -F %J$ docker container run \ --detach \ --name iot3 \ --rm \ -ti \ --network host \ -e http_proxy \ -e https_proxy \ -e no_proxy \ --user $(id -u):$(id -u) \ --mount type=bind,source=$(pwd),destination=$(pwd) \ --workdir $(pwd) \ python:3.11.14-slim-trixie \ /bin/bash -il $ docker container exec -u 0:0 iot3 apt update $ docker container exec -u 0:0 iot3 apt install -y git build-essential socat $ docker container exec -d iot3 socat UNIX-LISTEN:/tmp/mqtt.socket,fork TCP4:test.mosquitto.org:1884 $ docker container attach iot3/tmp/mqtt.socket.and packages' dependencies:
/tmp/iqm-unix.cfg/tmp/iqm-tcp.cfg/tmp/iqm-tls.cfg/tmp/iqm-wss.cfg(docker)🐍 $ pip --disable-pip-version-check --no-cache-dir \ install --no-deps python/*/dist/*.whl/tmp/iqm-unix.cfg:$ mosquitto_pub \ -h test.mosquitto.org -p 8886 \ --tls-version tlsv1.3 --capath /etc/ssl/certs/ \ -i H15/VGZbiFtxzPVrCrolUXbL \ -t 'default/inQueue/v2x/cam/0/1/2/3/3/2/1/0' \ -V 5 \ -m '["test-me"]'Expected results