【发布时间】:2017-08-22 17:58:43
【问题描述】:
https://www.hi-todd.com/websocket/
我用 MQTT 协议创建了一个演示,它在 HTTP 连接上运行良好。但是当我尝试将 HTTP 更改为 https 时,出现连接错误。
我在 mosquitto.conf 文件中添加了证书路径。跟大家分享一下 Mosquitto 的配置路径。
# WebSockets over TLS/SSL
listener 8083
protocol websockets
cafile /etc/mosquitto/ca_certificates/ca.crt
certfile /etc/mosquitto/ca_certificates/hi-todd_com.crt
keyfile /etc/mosquitto/ca_certificates/hi-todd_com.p7b
我使用了下面的库代码。
https://www.cloudmqtt.com/docs-websocket.html
【问题讨论】:
-
请阅读Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers? - 总结是这不是解决志愿者的理想方式,并且可能会适得其反。请不要将此添加到您的问题中。
-
您是自己生成证书还是为代理使用公共 CA?您是否在托管服务上的防火墙中打开了端口 8083,因为我无法连接到
config.js中的 IP 地址的端口 -
@hardillb 我正在使用公共 CA。是的,我的端口是开放的。我已经使用相同端口的 http 进行了测试,它工作正常。目前我已经更改了 mosquitto websocket emqtt 的端口和更改库。 github.com/emqtt/emqttd/wiki/WebSocket 但在这个库中也遇到了同样的问题。仅使用 ws 在 http 中工作。
-
你的 config.js 指向 8084 配置说 8083
-
@hardillb 对于 http,我使用了 8083,对于 Https,我使用了 8084。我使用了这个库 github.com/emqtt/emqttd/wiki/WebSocket。 Http 工作正常,但不是 https。
标签: websocket openssl mqtt wss