mqtt之mosquitto

https://www.cnblogs.com/y-c-y/p/11686916.html
https://blog.csdn.net/ptonlix/article/details/79869756
https://www.cnblogs.com/lexiaofei/p/8403995.html
https://www.cnblogs.com/y-c-y/p/11686916.html
http://www.pianshen.com/article/7955417306/

https://blog.csdn.net/qq_29350001/article/details/77161537 //good

//编译执行测试
//当需要添加用户时,有两种方法,一修改配置文件,给pc主机添加用户,推荐第一种
https://www.cnblogs.com/Paul-watermelon/p/10400758.html

//单向认证与双向认证
https://www.cnblogs.com/saryli/p/9821757.html

1、修改config.mk
prefix=/home/retry/mqtt_pc //指定自己的编译路径

2、编译
make WITH_SRV=no 

3、安装
make install


4、拷贝一份mosquitto.conf到etc目录下

5、测试
mosquitto -c /etc/mosquitto/mosquitto.conf   //启动代理
mosquitto_pub  -p 1883 -t "mqtt/server/topic" -m " hello,world"
mosquitto_sub  -p 1883 -t "mqtt/server/topic" 


二、ssl认证
1、修改mosquitto.conf文件

mosquitto -c /etc/mosquitto/mosquitto.conf   //启动代理
mosquitto_pub  -p 1883 -t "mqtt/server/topic" -m " hello,world" --cafile /etc/mosquitto/ca.crt --insecure
mosquitto_sub  -p 1883 -t "mqtt/server/topic" --cafile /etc/mosquitto/ca.crt --insecure

测试发现:--insecure不加会导致连接失败。
posted @ 2019-10-30 11:49  hostid  阅读(298)  评论(0)    收藏  举报