MAC 下配置MQTT 服务器Mosquitto | 少将全栈
  • 欢迎访问少将全栈,学会感恩,乐于付出,珍惜缘份,成就彼此、推荐使用最新版火狐浏览器和Chrome浏览器访问本网站。
  • 吐槽,投稿,删稿,交个朋友
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏少将全栈吧

MAC 下配置MQTT 服务器Mosquitto

开发笔记 admin 5年前 (2020-04-01) 88972次浏览 已收录 扫描二维码
macos下启动mqtt服务
brew install mosquitto
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 3 taps (jenkins-x/jx, homebrew/core and homebrew/cask).
==> New Formulae
llvm@9                                   vroom
==> Updated Formulae
jenkins-x/jx/jx ✔   gitfs               libgit2             rke
anycable-go         gitg                libgit2-glib        salt
apache-geode        gitless             libphonenumber      samurai
awscli              gnome-builder       literate-git        unrar
bee                 goreleaser          llvm                vapoursynth
dhall               graph-tool          manticoresearch     vapoursynth-imwri
dhall-json          helmfile            monero              vapoursynth-ocr
dhall-lsp-server    imapsync            oclgrind            vapoursynth-sub
dhall-yaml          janet               octant              vert.x
etcd                jenkins             pgformatter         wireguard-go
eye-d3              jfrog-cli-go        phpunit             xcodegen
firebase-cli        kyma-cli            rancher-cli         zabbix
fluent-bit          lazygit             ripgrep             zero-install
==> Updated Casks
5kplayer                   hbuilderx                  qt-creator
anydo                      imgotv                     rar
bibdesk                    iridium                    reaper
boinc                      joplin                     riot
cocktail                   lark                       scaleft
comparemerge               lego-mindstorms-ev3        script-debugger
dashcam-viewer             lehreroffice               snowflake-snowsql
downie                     lens                       sound-control
electorrent                marginnote                 sourcetrail
fedora-media-writer        megasync                   telegram
feishu                     microsoft-edge             telegram-desktop
freac                      mps                        use-engine
freeyourmusic              nightfall                  webcatalog
gnucash                    plex-media-server          yinxiangbiji
google-chrome              prezi-next
grandtotal                 protonmail-bridge
==> Deleted Casks
synfigstudio

==> Installing dependencies for mosquitto: libuv and libwebsockets
==> Installing mosquitto dependency: libuv
==> Downloading https://homebrew.bintray.com/bottles/libuv-1.35.0.catalina.bottl
==> Downloading from https://akamai.bintray.com/f9/f9e218fe31eec56662a5a10b0e736
######################################################################## 100.0%
==> Pouring libuv-1.35.0.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/libuv/1.35.0: 48 files, 3.0MB
==> Installing mosquitto dependency: libwebsockets
==> Downloading https://homebrew.bintray.com/bottles/libwebsockets-4.0.1.catalin
==> Downloading from https://akamai.bintray.com/a5/a5f2a171607549355e6958d260c94
######################################################################## 100.0%
==> Pouring libwebsockets-4.0.1.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/libwebsockets/4.0.1: 87 files, 1.4MB
==> Installing mosquitto
==> Downloading https://homebrew.bintray.com/bottles/mosquitto-1.6.9.catalina.bo
==> Downloading from https://akamai.bintray.com/fc/fcbdbcbd2f8abdb5880c6468a0c84
######################################################################## 100.0%
==> Pouring mosquitto-1.6.9.catalina.bottle.tar.gz
==> Caveats
mosquitto has been installed with a default configuration file.
You can make changes to the configuration by editing:
    /usr/local/etc/mosquitto/mosquitto.conf

To have launchd start mosquitto now and restart at login:
  brew services start mosquitto
Or, if you don't want/need a background service you can just run:
  mosquitto -c /usr/local/etc/mosquitto/mosquitto.conf
==> Summary
🍺  /usr/local/Cellar/mosquitto/1.6.9: 38 files, 997.1KB
==> Caveats
==> mosquitto
mosquitto has been installed with a default configuration file.
You can make changes to the configuration by editing:
    /usr/local/etc/mosquitto/mosquitto.conf

To have launchd start mosquitto now and restart at login:
  brew services start mosquitto
Or, if you don't want/need a background service you can just run:
  mosquitto -c /usr/local/etc/mosquitto/mosquitto.conf
(base)
 Wed  1 Apr - 08:52  ~ 
 @whatled  brew services start mosquitto
==> Successfully started `mosquitto` (label: homebrew.mxcl.mosquitto)
(base)

停止服务  brew services stop mosquitto

启动服务  brew services start mosquitto

mosquitto 服务器的配置环境文件路径 /usr/local/etc/mosquitto/mosquitto.conf

若连接不上mosquitto 服务器,可以检查配置文件

需要配置下mosquitto.conf ,解开IP和Port的注释

打开mosquitto.conf文件按照下面来配置你自己的IP和端口号

=================================================================

Default listener

=================================================================

IP address/hostname to bind the default listener to. If not

given, the default listener will not be bound to a specific

address and so will be accessible to all network interfaces.

bind_address ip-address/host name

#bind_address

Port to use for the default listener.

#port 1883

改成如下

bind_address 127.0.0.1

Port to use for the default listener.

port 1883

这边安装好后,启动用MQTTBox就可以直接连上了。

MacOs可以使用mqtt broker的软件:MQTTBox

MAC 下配置MQTT 服务器Mosquitto

GitHub地址:https://github.com/workswithweb/MQTTBox

官网网站的介绍为:使用MQTTBox增强你的物联网流程

MQTT客户端特性

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

负载测试MQTT的架构(MQTT设备和服务器)
可以定义发布/订阅的消息的速率
为同一个测试用例创建最多10个实例
可在仪表面板查看实时情况
使用图表查看测试结果
查看所有的发送和接收的负载测试数据
这款软件支持在Windows、Mac和Linux上面运行

 

 

喜欢 (3)
[🍬谢谢你请我吃糖果🍬🍬~]
分享 (0)
关于作者:
少将,关注Web全栈开发、项目管理,持续不断的学习、努力成为一个更棒的开发,做最好的自己,让世界因你不同。