首页 > 编程知识 正文

开源mqtt服务器比较,安卓机搭建mqtt服务器

时间:2023-05-03 18:28:00 阅读:28473 作者:198

MQTT概述:消息传递遥测传输(MQTT )基于轻量级代理的分发/订阅消息传输协议,设计思想开放、简单、轻量级、轻量级这些特征适用于受限的环境。 该合同的特点如下:

使用传递/订阅消息模式提供一对多的消息传递,并解除APP应用程序的绑定。 屏蔽了负载内容的消息传输。 使用TCP/IP提供网络连接。 传输大小小、开销少、固定长度的报头为2字节,将协议交换最小化,减少网络通信量。 一种使用Last Will和Testament特性向相关方客户端通知异常中断的机制。 具有“至多一次”三种信息发布服务质量,信息发布完全依赖于底层的TCP/IP网络。 会发生消息丢失或重复。 此级别表示环境传感器数据可以丢失一次读取记录。 因为最近有第二次发送。 “至少一次”允许消息到达,但可能会发生消息重复。 “只发送一次”,让信息只发送一次。 如果计费系统中的消息重复或丢失,结果不正确,则可以使用此级别。 二、构建MQTT服务器的apollo是活动消息的子项目,是活动消息的下一代消息代理。 apollo是在第一个ActiveMQ的基础上构建的更快、更可靠、更容易维护的消息代理。 要实现这一点,请使用完全不同的线程和消息调度体系结构。 与ActiveMQ一样,apollo是一个支持STOMP、AMQP、MQTT、Openwire、SSL和WebSockets的多协议代理。

下载地址: http://archive.Apache.org/dist/ActiveMQ/ActiveMQ-Apollo/1.7.1 /

必须先配置java环境https://jingyan.Baidu.com/article/495 ba 841 bbeee 138 b 30 ede 01.html

安装完成后,运行cmd。 apollo create mybroker

创建实例后,将在wldyb目录下生成mybroker文件夹,cd将移动到该目录并在CMD上运行。 apollo-broker.cmd run

以下错误loadingconfigurationfile ' d :phpstudyApache-Apollo-1.7.1wldybmy brokeretcApollo.XML

startup failed : Java.lang.noclassdeffounderror 3360 javax/XML/wldy BD/validation eventhandler

更改java jdk7版本进行解决(更改JDK版本后,更改环境变量不再有效的原因和解决方案C:WindowsSystem32目录中的java.exe、javaw.exe、)

web管理员,地址http://127.0.0.1:61680/or https://127.0.0.1336061681 /,默认帐户admin,密码password

更改mqtt服务器地址https://192.168.2.187336061681/console/index.html #

如果服务器需要互联网访问,则更改为0.0.0.0即可

? XML版本=' 1.0 '编码=' utf-8 '标准版='是'? -许可证保护软件基础设施(ASF ) underoneormorecontributorlicenseagreements.seethenoticefiledistributedwithisworkforadditionalinformationregardingcopyright etoyouundertheApachelicense,2.0版(the ' license ); youmaynotusethisfileexceptincompliancewiththelicense.youmayobtainacopyofthelicenseat http://www.Apache.org/licenses/许可证- 2.0 unlessrequiredbyapplicablelaworagreedtoinwriting, softwaredistributedunderthelicenseisdistributedonan ' asis ' bas ' basis ' license is withoutwarrantiesorconditionsofanykind,ees

d limitations under the License.--><!-- For more information on how configure this file please reference: http://activemq.apache.org/apollo/versions/1.7.1/website/documentation/user-manual.html --><broker xmlns="http://activemq.apache.org/schema/activemq/apollo"> <notes> The default configuration with tls/ssl enabled. </notes> <log_category console="console" security="security" connection="connection" audit="audit"/> <authentication domain="apollo"/> <!-- Give admins full access --> <access_rule allow="admins" action="*"/> <access_rule allow="*" action="connect" kind="connector"/> <virtual_host id="mybroker"> <!-- You should add all the host names that this virtual host is known as to properly support the STOMP 1.1 virtual host feature. --> <host_name>mybroker</host_name> <host_name>localhost</host_name> <host_name>192.168.2.187</host_name> <!-- Uncomment to disable security for the virtual host --> <!-- <authentication enabled="false"/> --> <!-- Uncomment to disable security for the virtual host --> <!-- <authentication enabled="false"/> --> <access_rule allow="users" action="connect create destroy send receive consume"/> <!-- You can delete this element if you want to disable persistence for this virtual host --> <leveldb_store directory="${apollo.base}/data"/> </virtual_host> <web_admin wldybd="http://192.168.2.187:61680"/> <web_admin wldybd="https://192.168.2.187:61681"/> <connector id="tcp" wldybd="tcp://0.0.0.0:61613" connection_limit="2000"/> <connector id="tls" wldybd="tls://0.0.0.0:61614" connection_limit="2000"/> <connector id="ws" wldybd="ws://0.0.0.0:61623" connection_limit="2000"/> <connector id="wss" wldybd="wss://0.0.0.0:61624" connection_limit="2000"/> <key_storage file="${apollo.base}/etc/keystore" password="password" key_password="password"/></broker>

PHP客户端开源代码
https://github.com/bluerhinos/phpMQTT

 

三、MQTTBox 的安装和使用

MQTTBox 是一个带有可视化的界面的 MQTT 的客户端工具,它具有如下特点:

支持 TCP、TLS、Web Sockets 和安全的 Web Sockets 连接 MQTT 服务器支持各种 MQTT 客户端的设置支持发布和订阅多个主题支持主题的单级和多级订阅复制/重新发布有效负载支持查看每个主题已发布/已订阅消息的历史记录

MQTTBox 启动后,点击“Create MQTT Client”按钮开始建立 MQTT 连接。

填写连接名称(可以随意输入)、协议和主机地址后,点击“Save”保存。

保存成功后进入如下的界面,顶部绿色“Connected”按钮表明当前 MQTT 连接已经成功。注意Topic名字要相同!

我们返回broker服务器查看,已经有msgs in 和out了

四、遇到的问题 1、解决“WARN  | java.lang.Error: java.net.BindException: Address already in use: wldybd INFO  | broker startup” 端口占用,需要关闭服务器上的apollo端口

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。