# Mosquitto broker WSS connection not working

**URL:** <https://forum.cedalo.com/t/mosquitto-broker-wss-connection-not-working/394>\
**Category:** Errors\
**Created:** [November 25, 2021, 12:40pm UTC](https://forum.cedalo.com/t/mosquitto-broker-wss-connection-not-working/394 "2021-11-25T12:40:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Theeran](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@Theeran](https://forum.cedalo.com/u/Theeran)\
**Post date:** [November 25, 2021, 12:40pm UTC](https://forum.cedalo.com/t/mosquitto-broker-wss-connection-not-working/394/1 "2021-11-25T12:40:39Z")

</div>

Im using Mosquitto 2.0.14 and running broker in my local system.(Broker + publisher + subscriber).

I created the required certs(ca, broker-server, client). Below is my simple configuration for WSS connection.

allow\_anonymous true  
password\_file C:\Mosquitto\password.txt

listener 1883  
protocol mqtt  
cafile C:\Mosquitto\certs\ca.crt  
keyfile C:\Mosquitto\certs\server.key  
certfile C:\Mosquitto\certs\server.crt

listener 8883  
protocol websockets  
cafile C:\Mosquitto\certs\ca.crt  
keyfile C:\Mosquitto\certs\server.key  
certfile C:\Mosquitto\certs\server.crt  
tls\_version tlsv1.2

log\_type all  
websockets\_log\_level 1023  
connection\_messages true

With the above configuration, im able to connect to plain MQTT. But tried to connect with WSS.

Im using Javascript client(html) and paho & mqtt.js client to connect to MQTT broker with WSS protocol. But its failing.

mqttws31.js:979 WebSocket connection to ‘wss://myLaptop:8084/mqtt’ failed:

Not able to connect with mosquitto\_pub and mosquitto\_sub.

Not sure what im missing.

Any suggestion would help.

---

<div class="post-metadata">

**Author:** ![roger.light](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@roger.light](https://forum.cedalo.com/u/roger.light)\
**Post date:** [November 27, 2021, 3:34pm UTC](https://forum.cedalo.com/t/mosquitto-broker-wss-connection-not-working/394/2 "2021-11-27T15:34:28Z")

</div>

The most common problem I see when using TLS connections is around certificates being correct. I would suggest trying the MQTT Explorer tool to try and connect, it has the option to completely disable certificate verification. If it succeeds with that option disabled but fails with it enabled, then the problem is with your certificates and/or the hostname you are using to connect - and I’ll be able to advise further.

Regards,

Roger

---

<div class="post-metadata">

**Author:** ![Theeran](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@Theeran](https://forum.cedalo.com/u/Theeran)\
**Post date:** [December 7, 2021, 6:12am UTC](https://forum.cedalo.com/t/mosquitto-broker-wss-connection-not-working/394/3 "2021-12-07T06:12:05Z")

</div>

HI Roger,

Yes i am able to connect to WS over TLS connection using MQTT Explorer tool by disabling the certificate.  
i created certificates from open ssl and the host name is, since im running mosquitto broker on local system i tried with localhost, and also the name i given while generating broker certificate and also ip address. but in all the above 3 cases, wss connection failed for me.
