Mosquitto broker WSS connection not working

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.

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

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.