【MQTT】在Windows下搭建MQTT服务器

MQTT,是IBM推出的一种针对移动终端设备的基于TCP/IP的发布/预订协议,可以连接大量的远程传感器和控制设备:

  • 轻量级的消息订阅和发布(publish/subscribe)协议
  • 建立在TCP/IP协议之上 
    物联网,MQTT在这方面应用较多

这里MQTT分

  • 客户端
  • 服务器端 
    网上的确有很多代码,但是服务器端的配置很少,而MQTT是通过TCP/IP协议连接的,MQTT是协议类型HTTP协议一样,也需要对应的服务器来运行 
    MQTT的官网:http://mqtt.org/

下面以服务器apache-apollo-1.7.1为例 下载地址http://activemq.apache.org/apollo/download.html

1、选择下载的电脑环境 如图 

2、在这里下载Apollo服务器,下载后解压。如下图所示: 

3、运行E:\apache-apollo-1.7.1\bin\apollo.cmd,输入create (名字)(名字任意取,这里是根据官网介绍的来取的)创建服务器实例,服务器实例包含了所有的配置,运行时数据等,并且和一个服务器进程关联。我这里是使用的是test

create 之后会在bin目录下生成对应文件夹 如图

4、打开cmd,运行E:\apache-apollo-1.7.1\bin\test\bin\apollo-broker.cmd run 开启服务器,如下图: 

5.可以在浏览器中输入 http://127.0.0.1:61681 如图


这样就安装完成了,该登录的用户名和密码在E:\apache-apollo-1.7.1\bin\test\etc\users.properties里,打开users.properties文件:

  ## ————————————————————————— 
  ## Licensed to the Apache Software Foundation (ASF) under one or more 
  ## contributor license agreements. See the NOTICE file distributed with 
  ## this work for additional information regarding copyright ownership. 
  ## The ASF licenses this file to You under the Apache License, Version 2.0 
  ## (the “License”); you may not use this file except in compliance with 
  ## the License. You may obtain a copy of the License at 
  ## 
  ## http://www.apache.org/licenses/LICENSE-2.0 
  ## 
  ## Unless required by applicable law or agreed to in writing, software 
  ## distributed under the License is distributed on an “AS IS” BASIS, 
  ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
  ## See the License for the specific language governing permissions and 
  ## limitations under the License. 
  ## —————————————————————————

  # 
  # The list of users that can login. This file supports both plain text or 
  # encrypted passwords. Here is an example what an encrypted password 
  # would look like: 
  # 
  # admin=ENC(Cf3Jf3tM+UrSOoaKU50od5CuBa8rxjoL) 
  #

  admin=password

登录后台之后 如图 



  <web_admin bind="http://127.0.0.1:61680"/>
  <web_admin bind="https://127.0.0.1:61681"/>


  <connector id="tcp" bind="tcp://0.0.0.0:61613" connection_limit="2000"/>
  <connector id="tls" bind="tls://0.0.0.0:61614" connection_limit="2000"/>
  <connector id="ws"  bind="ws://0.0.0.0:61623"  connection_limit="2000"/>
  <connector id="wss" bind="wss://0.0.0.0:61624" connection_limit="2000"/>


  <key_storage file="${apollo.base}/etc/keystore" password="password" key_password="password"/>
这里就可以看到 tcp/tls/ws/wss/对应端口 以及登录后台地址

登录后台选择configuration 的apollo.xml页面(http://127.0.0.1:61680/console/index.html) 修改tcp 对应的IP为自己电脑的本机IP,点击保存,此时可用本局域网中的客户端访问MQTT服务器,如此IP为公网IP,恭喜:可以外网访问了



  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值