{"id":79128,"date":"2024-01-11T21:04:42","date_gmt":"2024-01-11T13:04:42","guid":{"rendered":"https:\/\/www.techphant.cn\/?p=79128"},"modified":"2024-01-11T21:04:42","modified_gmt":"2024-01-11T13:04:42","slug":"symfwqdjfa","status":"publish","type":"post","link":"https:\/\/www.techphant.cn\/blog\/79128.html","title":{"rendered":"\u4f7f\u7528MQTT\u670d\u52a1\u5668\u642d\u5efa\u65b9\u6848"},"content":{"rendered":"

  MQTT\uff08Message Queuing Telemetry Transport\uff09\u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u53d1\u5e03\/\u8ba2\u9605\u6d88\u606f\u4f20\u8f93\u534f\u8bae\uff0c\u9002\u7528\u4e8e\u7269\u8054\u7f51\u8bbe\u5907\u4e4b\u95f4\u7684\u901a\u4fe1\uff0c\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecdMQTT\u670d\u52a1\u5668\u642d\u5efa\u65b9\u6848\u4ee5\u53ca\u5176\u5e94\u7528\u3002<\/p>\n

MQTT\u670d\u52a1\u5668\u6982\u8ff0<\/h2>\n

  MQTT\u670d\u52a1\u5668\u662f\u7528\u4e8e\u6d88\u606f\u4f20\u8f93\u7684\u4e2d\u95f4\u4ef6\uff0c\u8d1f\u8d23\u63a5\u6536\u3001\u5b58\u50a8\u548c\u8f6c\u53d1\u7269\u8054\u7f51\u8bbe\u5907\u4f20\u8f93\u7684\u6570\u636e\u3002\u642d\u5efaMQTT\u670d\u52a1\u5668\u9700\u8981\u8003\u8651\u670d\u52a1\u5668\u7aef\u8f6f\u4ef6\u7684\u9009\u62e9\u3001\u914d\u7f6e\u548c\u90e8\u7f72\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u5e38\u89c1\u7684MQTT\u670d\u52a1\u5668\u642d\u5efa\u65b9\u6848\u3002<\/p>\n

  Mosquitto MQTT\u670d\u52a1\u5668<\/h3>\n

  Mosquitto\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5f00\u6e90MQTT\u6d88\u606f\u4ee3\u7406\uff0c\u652f\u6301\u591a\u79cd\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5e76\u63d0\u4f9b\u4e86\u7b80\u5355\u6613\u7528\u7684\u914d\u7f6e\u65b9\u5f0f\u548c\u4e30\u5bcc\u7684\u6269\u5c55\u529f\u80fd\u3002\u642d\u5efaMosquitto\u670d\u52a1\u5668\u9700\u8981\u5b89\u88c5\u5bf9\u5e94\u7684\u8f6f\u4ef6\u5305\uff0c\u914d\u7f6e\u76d1\u542c\u7aef\u53e3\u548c\u6743\u9650\u63a7\u5236\u7b49\uff0c\u53ef\u4ee5\u901a\u8fc7Docker\u5feb\u901f\u90e8\u7f72\u3002<\/p>\n

  \u5b89\u88c5Mosquitto<\/h4>\n

  \u5728Ubuntu\u4e0a\u5b89\u88c5Mosquitto\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\uff1asudo apt-get install mosquitto mosquitto-clients\u3002\u7136\u540e\uff0c\u901a\u8fc7\u4fee\u6539\u914d\u7f6e\u6587\u4ef6mosquitto.conf\u6765\u914d\u7f6e\u670d\u52a1\u5668\u76d1\u542c\u7aef\u53e3\u3001\u8ba4\u8bc1\u65b9\u5f0f\u7b49\u3002<\/p>\n

  HiveMQ MQTT\u670d\u52a1\u5668<\/h3>\n

  HiveMQ\u662f\u4e00\u4e2a\u4e13\u4e1a\u7684MQTT\u6d88\u606f\u4ee3\u7406\uff0c\u5177\u6709\u9ad8\u6027\u80fd\u3001\u53ef\u6269\u5c55\u6027\u548c\u5b89\u5168\u6027\u3002HiveMQ\u63d0\u4f9b\u4e86\u4f01\u4e1a\u7ea7\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u652f\u6301\u96c6\u7fa4\u90e8\u7f72\u3001\u6570\u636e\u6301\u4e45\u5316\u548c\u5bf9\u5927\u89c4\u6a21\u8bbe\u5907\u7684\u7ba1\u7406\u3002<\/p>\n

  \u90e8\u7f72HiveMQ<\/h4>\n

  \u90e8\u7f72HiveMQ\u901a\u5e38\u9700\u8981\u6309\u7167\u5b98\u65b9\u6587\u6863\u63d0\u4f9b\u7684\u6b65\u9aa4\u8fdb\u884c\uff0c\u5305\u62ec\u5b89\u88c5Java Runtime Environment\uff08JRE\uff09\u3001\u4e0b\u8f7dHiveMQ\u8f6f\u4ef6\u5305\u3001\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u548c\u542f\u52a8\u670d\u52a1\u7b49\u64cd\u4f5c\u3002HiveMQ\u8fd8\u63d0\u4f9b\u4e86REST API\u548cWebSocket\u652f\u6301\uff0c\u9002\u5408\u590d\u6742\u7684\u7269\u8054\u7f51\u573a\u666f\u3002<\/p>\n

MQTT\u670d\u52a1\u5668\u5728\u7269\u8054\u7f51\u4e2d\u7684\u5e94\u7528<\/h2>\n

  MQTT\u670d\u52a1\u5668\u5728\u7269\u8054\u7f51\u4e2d\u626e\u6f14\u7740\u6838\u5fc3\u89d2\u8272\uff0c\u5b83\u8fde\u63a5\u4e86\u5404\u79cd\u8bbe\u5907\u3001\u4f20\u611f\u5668\u548c\u5e94\u7528\u7a0b\u5e8f\uff0c\u4e3a\u6570\u636e\u4f20\u8f93\u548c\u5b9e\u65f6\u901a\u4fe1\u63d0\u4f9b\u4e86\u53ef\u9760\u7684\u57fa\u7840\u3002\u901a\u8fc7\u642d\u5efaMQTT\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u5b9e\u73b0\u667a\u80fd\u5bb6\u5c45\u3001\u5de5\u4e1a\u81ea\u52a8\u5316\u3001\u667a\u80fd\u519c\u4e1a\u7b49\u5404\u79cd\u573a\u666f\u4e0b\u7684\u901a\u4fe1\u548c\u63a7\u5236\u3002<\/p>\n

  \u667a\u80fd\u5bb6\u5c45<\/h3>\n

  \u5728\u667a\u80fd\u5bb6\u5c45\u7cfb\u7edf\u4e2d\uff0cMQTT\u670d\u52a1\u5668\u53ef\u4ee5\u5c06\u5bb6\u5ead\u8bbe\u5907\u5982\u706f\u5149\u3001\u6e29\u5ea6\u4f20\u611f\u5668\u3001\u5b89\u9632\u7cfb\u7edf\u7b49\u8fde\u63a5\u8d77\u6765\uff0c\u5b9e\u73b0\u8fdc\u7a0b\u63a7\u5236\u548c\u667a\u80fd\u5316\u7ba1\u7406\u3002\u5bb6\u5ead\u6210\u5458\u53ef\u4ee5\u901a\u8fc7\u624b\u673a\u5e94\u7528\u5b9e\u65f6\u76d1\u63a7\u548c\u8c03\u8282\u5bb6\u4e2d\u8bbe\u5907\uff0c\u63d0\u9ad8\u751f\u6d3b\u8212\u9002\u5ea6\u548c\u8282\u80fd\u6548\u679c\u3002<\/p>\n

  \u5de5\u4e1a\u81ea\u52a8\u5316<\/h3>\n

  \u5de5\u4e1a\u9886\u57df\u7684\u4f20\u611f\u5668\u548c\u63a7\u5236\u8bbe\u5907\u9700\u8981\u9ad8\u6548\u7a33\u5b9a\u7684\u901a\u4fe1\u65b9\u5f0f\uff0cMQTT\u670d\u52a1\u5668\u901a\u8fc7\u5176\u4f4e\u5f00\u9500\u3001\u80fd\u8017\u4f4e\u7684\u7279\u6027\uff0c\u6210\u4e3a\u4e86\u5de5\u4e1a\u81ea\u52a8\u5316\u9886\u57df\u7684\u9996\u9009\u3002MQTT\u670d\u52a1\u5668\u5728\u5de5\u5382\u81ea\u52a8\u5316\u3001\u4f9b\u5e94\u94fe\u7ba1\u7406\u3001\u8bbe\u5907\u76d1\u63a7\u7b49\u65b9\u9762\u53d1\u6325\u7740\u91cd\u8981\u4f5c\u7528\u3002<\/p>\n

\u603b\u7ed3<\/h2>\n

  \u672c\u6587\u4ecb\u7ecd\u4e86MQTT\u670d\u52a1\u5668\u7684\u642d\u5efa\u65b9\u6848\u4ee5\u53ca\u5728\u7269\u8054\u7f51\u4e2d\u7684\u5e94\u7528\u3002<\/strong>\u901a\u8fc7\u9009\u7528\u5408\u9002\u7684MQTT\u670d\u52a1\u5668\uff0c\u53ef\u4ee5\u652f\u6301\u5404\u79cd\u89c4\u6a21\u548c\u9700\u6c42\u7684\u7269\u8054\u7f51\u573a\u666f\uff0c\u4e3a\u8bbe\u5907\u4e4b\u95f4\u7684\u901a\u4fe1\u63d0\u4f9b\u53ef\u9760\u3001\u9ad8\u6548\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u63a8\u52a8\u7269\u8054\u7f51\u6280\u672f\u7684\u53d1\u5c55\u548c\u5e94\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

MQTT\uff08MessageQueuingTelemetryTransport\uff09\u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u7684\u53d1\u5e03\/\u8ba2\u9605\u6d88\u606f\u4f20\u8f93\u534f\u8bae\uff0c\u9002\u7528\u4e8e\u7269\u8054\u7f51\u8bbe\u5907\u4e4b\u95f4\u7684\u901a\u4fe1\uff0c\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecdMQTT<\/p>\n","protected":false},"author":1,"featured_media":64183,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"categories":[36],"tags":[46],"class_list":["post-79128","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog","tag-m"],"_links":{"self":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/79128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/comments?post=79128"}],"version-history":[{"count":0,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/posts\/79128\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media\/64183"}],"wp:attachment":[{"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/media?parent=79128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/categories?post=79128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techphant.cn\/wp-json\/wp\/v2\/tags?post=79128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}