连接服务器失败,要么是是本地参数没设对, 要么服务器没开!
使用Kafka发送消息好搞,按照 /opt/nvidia/deepstream/deepstream-6.2/sources/libs/kafka_protocol_adaptor/README 一步一步来就行了,前提是要搞kafka 环境搭建开启, 这个在README 里面是没有提到的。
kafka 环境搭建
1. 安装jdk
$ apt-get update && apt-get install openjdk-8-jdk
2. 安装kafka
https://www.apache.org/dyn/closer.cgi?path=/kafka/3.3.1/kafka_2.13-3.3.1.tgz
$ tar -xzf kafka_2.13-3.3.1.tgz
$ cd kafka_2.13-3.3.1
3 开启两个服务器
3.1 Start the ZooKeeper service
$ ./bin/zookeeper-server-start.sh config/zookeeper.properties
3.2 start a new teminal, Start the Kafka broker service
$ ./bin/kafka-server-start.sh config/server.properties
4. 测试kafka
4.1 创建主题,这条命令只用执行一次,执行完会自己退出。
$ ./bin/kafka-topics.sh --create --topic mytopic --bootstrap-server localhost:9092
4.2 开启消费者
$ ./bin/kafka-console-consumer.sh --topic mytopic --from-beginning --bootstrap-server localhost:9092
5. Deepstream 推消息
$ cd /opt/nvidia/deepstream/deepstream-6.2/sources/apps/sample_apps/deepstream-test4
配置好
dstest4_config.yml
msgbroker:
proto-lib: /opt/nvidia/deepstream/deepstream-6.2//lib/libnvds_kafka_proto.so
conn-str: localhost;9092
topic: mytopic
$ ./deepstream-test4-app dstest4_config.yml
即可
下面才是今天重点,Rabbitmq !
1. 安装Rabbitmq 开启服务
按照 /opt/nvidia/deepstream/deepstream-6.2/sources/libs/amqp_protocol_adaptor/README
$sudo service rabbitmq-server status
Running 即可
make 后测试
./test_amqp_proto_async
./test_amqp_proto_sync
都没有问题,下面创建exchange, Queue, Bind Queue to exchange
2. Deepstream 推消息
使用
$ ./deepstream-test4-app -i …/…/…/…/samples/streams/sample_720p.h264 -p /opt/nvidia/deepstream/deepstream-6.2/lib/libnvds_amqp_proto.so --conn-str=“localhost;5672;guest;guest” --topic=topicname -s 0
没有问题,但是
如果按照官方文档kafaka模板更改
dstest4_config.yml
msgbroker:
proto-lib: /opt/nvidia/deepstream/deepstream-6.2/lib/libnvds_amqp_proto.so
conn-str: localhost;5672
topic: topicname
sync: 0
$ ./deepstream-test4-app dstest4_config.yml
问题来了,报错:
ERROR from element nvmsg-broker: Could not configure supporting library.
Error details: /dvs/git/dirty/git-master_linux/deepstream/sdk/src/gst-plugins/gst-nvmsgbroker/gstnvmsgbroker.cpp(401): legacy_gst_nvmsgbroker_start (): /GstPipeline:dstest4-pipeline/GstNvMsgBroker:nvmsg-broker:
unable to connect to broker library
再次更改dstest4_config.yml,添加用户名密码
msgbroker:
proto-lib: /opt/nvidia/deepstream/deepstream-6.2/lib/libnvds_amqp_proto.so
#conn-str: localhost;5672
conn-str: localhost;5672;guest;guest
topic: topicname
sync: 0
$ ./deepstream-test4-app dstest4_config.yml
跑起来了!
3. 查看Rabbitmq 消息
浏览器输入:http://localhost:15672