Search code examples
javascriptmqttpaho

Browsers return error "the operation is insecure" when using Paho MQTT


I made a small web chat with JavaScript and Paho MQTT, but neither Firefox nor Edge (i.e. the browsers I have tried) let me connect to the broker broker.hivemq.com. Firefox says that the operation is insecure.

image of error

I use this MQTT client:

<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.js" type="text/javascript"></script>

Here's my GitHub project.


Solution

  • If you load a page via HTTPS it will NOT allow you to make a none secure WebSocket connection to the remote host. You MUST use wss:// (secure websockets)