前端调用mqtt不能使用1883端口的问题

时间:2020-05-23 21:39:37   收藏:0   阅读:786

不知为何,前端ws访问1883端口总是失败

在阿里云服务器配置了mosquitto消息服务器

添加更改配置文件 /etc/mosquitto/conf.d/myconfig.conf

 1 # 配置mosquitto支持websocket,且监听端口号为8083
 2 port 1883
 3 listener 8083
 4 protocol websockets
 5 
 6 # 关闭匿名访问,客户端必须使用用户名
 7 allow_anonymous false
 8 
 9 #指定 用户名-密码 文件
10 password_file /etc/mosquitto/pwfile.txt

这样,前端就可以用 client = mqtt.connect(ws://120.79.x.x:8083,options)  来访问了

原文:https://www.cnblogs.com/nuister/p/12944058.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!