我与Ratchet库建立了websocket聊天。使用普通模式(ws://)它运行良好,但是使用安全模式(wss://)则没有。
我已经检查并找到了应该与stunnel一起使用的解决方案。我已按如下方式安装和配置了stunnel:
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
但它也不起作用:(。
以下是用于连接websocket服务器的客户端代码:
// 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!");
};
我该如何解决这个问题?还在使用Stunnel(如何修复?)或使用其他工具和Ratchet库? 谢谢!