开启 mqtt
插件
1
| ~/rabbitmq-server/sbin/rabbitmq-plugins enable rabbitmq_mqtt
|
配置
1
| vim ~/rabbitmq-server/etc/rabbitmq/rabbitmq.conf
|
写入配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| mqtt.listeners.tcp.1 = 1883 mqtt.listeners.tcp.2 = 1884
mqtt.default_user = guest mqtt.default_pass = guest
mqtt.allow_anonymous = false mqtt.vhost = / mqtt.exchange = amq.topic
mqtt.subscription_ttl = 1800000
mqtt.prefetch = 10
mqtt.durable_queue_type = quorum
mqtt.retained_message_store = rabbit_mqtt_retained_msg_store_ets
mqtt.retained_message_store_dets_sync_interval = 2000
|
创建用户和 vhost
1 2 3 4 5 6 7 8 9 10 11
| ~/rabbitmq-server/sbin/rabbitmqctl add_vhost ,mqtt_vhost
~/rabbitmq-server/sbin/rabbitmqctl list_users ~/rabbitmq-server/sbin/rabbitmqctl change_password guest guest
~/rabbitmq-server/sbin/rabbitmqctl add_user maxzhao maxzhao
~/rabbitmq-server/sbin/rabbitmqctl set_user_tags maxzhao administrator
~/rabbitmq-server/sbin/rabbitmqctl set_permissions -p / maxzhao ".*" ".*" ".*"
|
客户端接入
1 2
| username:mqtt_vhost:maxzhao password:maxzhao
|
RabbitMQ 不支持 Qos2,会被降级到Qos1。
本文地址: https://github.com/maxzhao-it/blog/post/c4ae7068/