How to add nvmsgbroker to a pipeline in Python

• Hardware Platform (Jetson / GPU) : GPU
• DeepStream Version : 7.0
• TensorRT Version : 8.6.1
• NVIDIA GPU Driver Version (valid for GPU only) : 535.171.04
• Issue Type( questions, new requirements, bugs) : questions

Hello,
Could you point me in the right direction on how to add the nvmsgbroker to a pipeline using Python?

I have just added it to the end of the pipeline, but after setting the conn-str and the proto-lib like this:

self.nvmsgbroker.set_property("conn-str", "mqtt-broker;1883;my_username")
self.nvmsgbroker.set_property("proto-lib", "/opt/nvidia/deepstream/deepstream/lib/libnvds_mqtt_proto.so")

I get this error message:

ERROR: gst-library-error> -quark: Could not configure supporting library. (5): gstnvmsgbroker.cpp(437): legacy_gst_nvmsgbroker_start (): /GstPipeline:pipeline0/GstNvMsgBroker:nvmsgbroker:
unable to connect to broker library

To clarify, the mqtt-broker in my conn-string is the name of an eclipse-mosquitto:2 docker container that I have on the same docker network.

Could you point me to an example application in python?
Thank you for your help!

Hi

Try something like

conn-str = localhost;1883
config   = <pathname of MQTT configuration file>

With a config file

[message-broker]
username = user
password = password

Here you can find more info Gst-nvmsgbroker — DeepStream documentation

Regards,
Allan Navarro
Embedded SW Engineer at RidgeRun

Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/
Website: www.ridgerun.com

from the error, it is because connecting broker failed. you can use the tool to test first. the tool path is /opt/nvidia/deepstream/deepstream/sources/libs/mqtt_protocol_adaptor/.

Hi @allan.navarro and @fanzh,
Thank you for your help!

This worked, thanks! I was turned around by the documentation’s earlier parts, so I have not made it to this part that was useful for my use-case.

Instead of localhost, I could just use the name of the container, as they are on the same docker network.

I have another question about this topic: I have modified the nvmsgconv, so that it includes a custom string in the otherAttrs field (see this topic), but it does not get sent via MQTT.

Could you help me with what could be the issue here, and how to fix it?

Hi @levay

Could you print the generated message here

diff --git a/sources/libs/nvmsgconv/deepstream_schema/eventmsg_payload.cpp b/sources/libs/nvmsgconv/deepstream_schema/eventmsg_payload.cpp
index d345289..3c23dbe 100644
--- a/sources/libs/nvmsgconv/deepstream_schema/eventmsg_payload.cpp
+++ b/sources/libs/nvmsgconv/deepstream_schema/eventmsg_payload.cpp
@@ -779,6 +779,7 @@ gchar* generate_event_message (void *privData, NvDsEventMsgMeta *meta)
   json_node_set_object (rootNode, rootObj);
 
   message = json_to_string (rootNode, TRUE);
+  //Add print here
   json_node_free (rootNode);
   json_object_unref (rootObj);

just to make sure it’s there

Regards,
Allan Navarro
Embedded SW Engineer at RidgeRun

Contact us: support@ridgerun.com
Developers wiki: https://developer.ridgerun.com/
Website: www.ridgerun.com

Sorry for the late reply, Is this still an DeepStream issue to support? Thanks!

Hi @allan.navarro,
Thank you for the reply!

Due to this, I have recognized, that I have added the custom code to a wrong line in the code, due to a Github merging mishap (:
So all in all, it works now, I see the MQTT message complete with our custom payload. Thanks again!

Well, it was, but with the help above, it is solved now.

Thank you all for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.