I have built websocket chat with Ratchet library. With normal mode (ws://) it works well, but with secure mode (wss://) it does not.
I have checked and found the solution that should work with stunnel. I have installed and configured the stunnel as below:
sslVersion = all
options = NO_SSLv2
cert = /vagrant/public/local.dev/ssl/<filename>.cert
CApath = /vagrant/public/local.dev/ssl
CAfile = /vagrant/public/local.dev/ssl/<filename>.cacert
key = /vagrant/public/local.dev/ssl/<filename>.key
;verify = 2
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
debug = 7
output = /var/log/stunnel.log
client = yes
[wss]
accept = 9020
connect = 9019
TIMEOUTclose = 0
But it does not work too :(.
Below is client code using to connect websocket server:
// var conn = new WebSocket('ws://local.dev:9019'); --> work, but I want to work with wss
//var conn = new WebSocket('ws://local.dev:9020'); --> don't work
// var conn = new WebSocket('wss://local.dev:9019'); --> don't work
var conn = new WebSocket('wss://local.dev:9020'); --> don't work
conn.onopen = function(e) {
console.log("Connection established!");
};
How could I solve this issue? Still using Stunnel (how to fix?) or using other tool with Ratchet library? Thanks!