Reputation: 121
I need to connect to broker over websocket.
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js" type="text/javascript"></script>
<script>
// Create a client instance
client = new Paho.MQTT.Client("broker.hivemq.com", 8000, "" , "gokden");
// connect the client
client.connect({onSuccess:onConnect});
function onConnect(){
console.log("Connected!");
}
</script>
This is my connection code but i get this error:
mqttws31.min.js:36 Mixed Content: The page at 'karantinagunlugum.com' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://broker.hivemq.com:8000/'. This request has been blocked; this endpoint must be available over WSS.
Upvotes: 0
Views: 2129
Reputation: 59751
You have 2 related but separate problems here.
You have 2 choices
You shouldn't really be using broker.hivemq.com for anything other than basic testing and playing, if you want to do anything serious you should be either paying for a properly hosted broker or running your own.
Upvotes: 1