我正在尝试在客户端使用WebSocket Secure (wss)配置Kamailio。除了允许端口和重定向之外,我还在kamailio.cfg和tls.cfg上设置了设置。在我的浏览器控制台上,我看到了:jssip-3.0.13.js:21334 WebSocket connection to 'wss://mydomain.com:4443/' failed: WebSocket opening handshake was canceled
但是,如果我使用ws ('ws://mydomain.com:8080/'),它就能工作。
有人知道怎么解决这个问题吗?
我生成了证书,但问题仍然存在。我正在使用nodeJS作为服务器。
kamailio.cfg文件:
/*添加本地域别名*/
alias="mydomain.com“
listen=udp:private_ip:5060广告public_ip:5060
listen=tcp:private_ip:5060广告public_ip:5060
listen=tcp:private_ip:5061广告public_ip:5061
listen=MY_WS_ADDR广告public_ip:8080
listen=tls:private_ip:4443广告public_ip:5061
“#!如果是WITH_TLS
listen=MY_WSS_ADDR广告public_ip:4443
“#!
tcp_connection_lifetime=3604
tcp_accept_no_cl=yes
tcp_rd_buf_size=16384
收听/*端口( udp、tcp、scrtp默认为5060,tls默认为5061 )*/
"# port=5060
..。
“#!定义WITH_NAT”
“#!定义WITH_MYSQL”
“#!定义WITH_AUTH
“#!定义WITH_USRLOCDB”
“#!定义WITH_TLS”
“#!定义WITH_DEBUG”
"#!substdef "!MY_IP_ADDR!my_private_ip!g“
"#!substdef "!MY_DOMAIN!my_public_ip!g“
"#!substdef "!MY_WS_PORT!8080!g“
"#!substdef "!MY_WSS_PORT!4443!g“
"#!substdef "!MY_WS_ADDR!tcp:MY_IP_ADDR:MY_WS_PORT!g“
"#!substdef "!MY_WSS_ADDR!tls:MY_IP_ADDR:MY_WSS_PORT!g“
额外信息 event_routexhttp:request等于Kamailio5.0文档:https://kamailio.org/docs/modules/5.0.x/modules/websocket.html .
tls.cfg文件:
..。
服务器:默认
方法= TLSv1
verify_certificate = no
require_certificate =是
private_key = /etc/certs/mydomain.com/key.pem
证书= /etc/certs/mydomain.com/cert.pem
..。
..。
客户端:默认
verify_certificate =是
require_certificate =是
..。
Javascript:
var socket = new JsSIP.WebSocketInterface('wss://mydomain.com:4443');
var configuration = {
sockets : [ socket ],
uri : 'sip:client@mydomain.com',
password : '******',
};NodeJS:
'use strict';
var os = require('os');
var path = require('path');
const https = require('https');
var url = require('url');
const fs = require('fs');
const options = {
key: fs.readFileSync('demoCA/key.pem'),
passphrase: '*********',
cert: fs.readFileSync('demoCA/cert.pem')
};
var app = https.createServer(options, function(req, resp) {
var url_parts = url.parse(req.url);
var path = url_parts.pathname;
console.log(path)
fs.readFile(__dirname + path, function(err, data) {
if(err) {
resp.writeHead(404, {'Content-Type': 'text/html'});
resp.write('Not found');
} else {
resp.writeHead(200, {'Content-Type': 'text/html'});
resp.write(data);
}
resp.end();
});
});
app.listen(443);AWS
侦听
udp: private_ip:5060 advertise public_ip:5060
tcp: private_ip:5060 advertise public_ip:5060
tcp: private_ip:5061 advertise public_ip:5061
tcp: private_ip:8080 advertise public_ip:8080
tls: private_ip:4443 advertise public_ip:4443别名:
tls: ip-private_ip.us-west-2.compute.internal:4443
tcp: ip-private_ip.us-west-2.compute.internal:8080
tcp: ip-private_ip.us-west-2.compute.internal:5061
tcp: ip-private_ip.us-west-2.compute.internal:5060
udp: ip-private_ip.us-west-2.compute.internal:5060如果你需要更多的细节,问我,所以我会编辑我的问题。
发布于 2017-09-05 02:27:35
我解决了我的问题。我丢失了一些模块和路由器。
我以这个文件为例:https://gist.github.com/jesusprubio/4066845,但重要的是要知道每个模块--开始时的"mi“--它们在Kamailio5.0上不是支持的。您需要替换相对于5.0版本的模块。
我使用这个站点来生成证书:certbot.eff.org/#ubuntuxenial nginx
我希望这能帮上忙。
https://stackoverflow.com/questions/45919480
复制相似问题