Error in WebSocket Connection for MQTT Over HTTPS #1952
Unanswered
CD-rajveer
asked this question in
Q&A
Replies: 3 comments 1 reply
-
Please provide the script you are using to connect, I have a feel you are using |
Beta Was this translation helpful? Give feedback.
0 replies
-
console.log("Final Payload:", payload);
console.log("Final Payload (Parsed):", JSON.parse(payload));
const mqttBrokerUrl = `wss://${selectedDevice?.ip_address}:{port}`;
console.log("MQTT IP set dynamically: ", mqttBrokerUrl);
const client = mqtt.connect(mqttBrokerUrl, options);
client.on("connect", () => {
console.log("MQTT client connected");
client.publish(mqtt_topic, payload, (error) => {
if (error) {
console.error("Error publishing to MQTT:", error.message);
setPushConfigSnackbar({
open: true,
message: "Failed to publish configuration.",
});
client.end(); // Close connection on error
return;
} I have used wss as well but I guess broker should support wss |
Beta Was this translation helpful? Give feedback.
1 reply
-
Yeah, I fixed that typo, I will check the broker side |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm encountering an issue when trying to connect to an MQTT broker using WebSocket (ws://) from a website served over HTTPS. The browser throws an error:
Environment
MQTT Broker: Hosted at mqtt://IP_ADDRESS:PORT (non-secure WebSocket).
Frontend: Hosted on URL Via HTTPs
Nginx Configuration: Serves frontend over HTTPS but proxies WebSocket traffic to an insecure broker (ws://)
Potential Solutions Attempted
Configured Nginx as a reverse proxy but failed to establish wss:// successfully.
Considered direct MQTT broker configuration changes to enable wss://, but this requires additional SSL setup.
Beta Was this translation helpful? Give feedback.
All reactions