如何在HTTPS服务器上连接MQTT?

时间:2017-08-22 09:42:34

标签: https mqtt mosquitto

我们在HTTPS服务器中遇到MQTT连接问题。有时它工作正常,有时会出现如下错误。

与'wss:// MYHOST:8083 / mqtt'的WebSocket连接失败:连接建立错误:net :: ERR_INSECURE_RESPONSE

让我与您分享,

我的mosquitto.conf文件:

pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
listener 1883


listener 8083 
protocol websockets
certfile /etc/mosquitto/certs/myhost.crt
cafile /etc/mosquitto/certs/ca.crt
keyfile /etc/mosquitto/certs/myhost.key

我的Mosquitto WebSocket配置文件:

host = 'MYHOST'; // hostname or IP address 
port = 8083;
topic = 'TOPIC'; // topic to subscribe to
useTLS = true;
username = "";
password = "";
path = "/mqtt";
cleansession = true;

请给我解决方案。

谢谢!

此致 Karmdip Joshi

1 个答案:

答案 0 :(得分:1)

我在几天之前得到了相同的错误,并从hardillb获得了解决方案。

请按照下面的stackoverflow网址进行操作并尝试!!

Websocket is not working with SSL

感谢。