搭建Coolpy+MQTT 服务


本文摘自网络,作者,侵删。

搭建Coolpy+MQTT 服务

下载

  • # 官网
    http://coolpy.net/
    # 主服务
    https://github.com/Coolpy7/Coolpy7
    # 拓展服务
    https://github.com/Coolpy7/coolpy7_extend_service
    

拓展服务实现账号密码验证

  • 启动

    # 启动coolpy7_extend_service 启动参数
    # l 当前服务Host地址 (默认为:5683即本地5683端口,此参数一般默认即可,
    #                            无需配置, 使用UDP连接请开启相关防火墙设置)
    # ht 内核扩展功能服务token,(必须与客户端配置一致)
    go run coolpy7_extend_service.go -ht=coolpy7
    # 启动成功后会打印如下信息,即说明服务端已正常启动,host于5683端口,请确保相关防火墙配置可用
    2020/01/15 10:55:33 coolpy7 extend server on udp port :5683
    
    # 后台启动
    ## build
    go build coolpy7_extend_service.go
    ## 提权
    chmod +x coolpy7_extend_service
    nohup ./oolpy7_extend_service -ht=coolpy7 >> run.log 2>&1 &;
    

启动主服务

  • 启动

    # 解压文件
    unzip go_build_Coolpy7_go_linux.zip
    # 提权
    chmod -R 777 go_build_Coolpy7_go_linux
    或
    chmod +x go_build_Coolpy7_go_linux
    # 启动
    ./go_build_Coolpy7_go_linux
    # 后台启动
    nohup ./go_build_Coolpy7_go_linux >> run.log 2>&1 &;
    # 带拓展服务启动
    # 启动Coolpy7 启动参数
    # as参数,启动扩展服务功能,(关闭默认的禁用连接身份认证功能)
    # ha参数,扩展服务器所在地址,本例为192.168.101.4:5683
    # ht参数,服务器连接验证密钥,必须与扩展服务启动参数中的ht参数一致,否则无法与之通信
    # 若127.0.0.1 验证不成功则使用具体ip;如192.168.21.224
    ./go_build_Coolpy7_go_linux -as=false -ha=127.0.0.1:5683 -ht=coolpy7
    
    # 启动时测试连接扩展服务器结果显示
    2020/01/15 11:30:04 connected to coolpy7 extend service 127.0.0.1:5683
    # 启动成功后会打印如下信息,即说明服务端已正常启动,host于1883端口,请确保相关防火墙配置可用
    2020/01/15 11:30:04 Coolpy7 v7.2.1.1 tcp [::]:1883 plugin build golang v1.13.1
    
  • 启动参数

    https://coolpy7.gitbook.io/coolpy7book/kai-shi-shi-yong/qi-dong-can-shu

    Usage of ./go_build_Coolpy7_go:
      -as
            用户身份验证默认开关,true为不验证,false为通过插件验证 (default true)
      -crk string
            集群服务发现验证token (default "Coolpy7!@#$dRdT(")
      -crp int
            集群发现端口(UDP) (default 7946)
      -csk string
            集群服务同步验证token (default "Coolpy7")
      -csp int
            集群同步端口(UDP) (default 7947)
      -dt int
            心跳或推送消息限制生效后,多少时间内不允许登陆/秒 (default 0)
      -ha string
            内核扩展功能服务地址,as参数为false此参数生效 (default "localhost:5683")
      -ht string
            内核扩展功能服务token,必须与服务端配置一致(default 'coolpy7') (default "coolpy7")
      -it int
            消息ID标记缓存超时时间/秒, 默认0即不执行超时删除 (default 0)
      -l string
            绑定Host地址 (default ":1883")
      -max int
            GOMAXPROCS (default 1024)
      -mbs string
            连接集群节点(192.168.0.100,192.168.0.101)
      -mc int
            允许接入客户端最大连接数,0为不限制 (default 0)
      -mpl int
            允许单个消息体最大体积/单位Byte,0为不限制 (default 0)
      -nid string
            集群节点名称,必须集群中唯一
      -nt int
            空连接攻击最大值,多少时间内连接未正常登陆后关闭连接/秒 (default 2)
      -ol int
            集群节点离线重连最少间隔时间/秒 (default 30) (default 10)
      -ot int
            消息IO缓存超时时间/秒,默认0即不执行超时删除 (default 0)
      -pl int
            心跳包最少间隔时间/秒,少于此值ping包自动关闭连接 (default 0)
      -psl int
            推送消息最少间隔时间/豪秒(千分之一秒),少于此值publish消息自动关闭连接 (default 0)
      -rt int
            Retained消息缓存超时时间/秒, 默认0即不执行超时删除 (default 0)
      -st int
            订阅缓存超时时间/秒, 默认0即不执行超时删除 (default 0)
      -t int
            connection read write timeout second (default 60)
      -wt int
            will消息缓存超时时间/秒, 默认0即不执行超时删除 (default 0)
    
  • 测试

    工具:MQTTBox.exe


本文来自:简书

感谢作者:我是不会赢的

查看原文:搭建Coolpy+MQTT 服务

相关阅读 >>

手撸Golang 架构设计原则 里氏替换原则

又掉进slice切片的坑里面了

Go语言如何判断变量是slice还是array

Golang怎么把字符串转成int类型

基于Golang的手机号格式验证和邮箱格式验证

关于 Go 并发编程之 mutex

你还在手撕微服务?快试试 Go-zero 的微服务自动生成

Golang 1.9什么时候发布

Go cloud项目开源发布:Go语言将成为云端应用开发的首选语言?

Golang实现数组模拟环形队列

更多相关阅读请进入《Go》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...