-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow topic per message for mosquitto_pub --stdin-line
#3060
Comments
I came here today to search for this exact feature, came across the same StackOverflow article. My need is to pipe mosquitto_sub to mosquitto_pub to send retained messages from one broker to the other (I don't have access to the mosquitto.db file). |
To address the use case above, git-developer/pimper can be used as workaround until this feature is implemented. It is a gateway between file system pipes and MQTT. |
This is a feature request to extend
mosquitto_pub --std-line
so that it allows a separate topic per message.Use case
mosquitto_pub
can be used as bridge between a program in a linux shell and an MQTT broker. The argument--std-line
supports this efficiently because it allows to establish the MQTT connection once for an arbitrary number of messages. Unfortunately this is limited to a single topic for all messages.There are scenarios where the topic depends on the message. Let's take this simple example (borrowed from a real StackOverflow question) where a program outputs values of different thermometers:
Imagine we'd like to send these values to a broker using a topic per thermometer, e.g.
sensors/temp_0d
,sensors/temp_02
,sensors/temp_04
. If we do this withmosquitto_pub
, a connection is established for each message. This is very inefficient for a high message count, even more if TLS is used.This could be improved by establishing a single connection once and configuring the topic per message. Example (fictive syntax):
The desired effect is that
mosquitto_pub
establishes a single connection and then sends three messages with the following arguments-t sensors/temp_0d -m '23.5 C'
-t sensors/temp_02 -m '11.3 C'
-t sensors/temp_04 -m '5.0 C'
The requested behavior might be achieved by using/coding another mqtt client, but I think it's a common use case for users of
mosquitto_pub
.References
The text was updated successfully, but these errors were encountered: