我正在尝试使用已经运行的 SIP 服务器与 JSSip 建立连接。我遵循了文档并提出了以下代码。这是我的代码。
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
</head>
<body></body>
<script src="jssip-3.0.0.min.js"></script>
<script>
var socket = new JsSIP.WebSocketInterface('wss://sip.group.com');
var configuration = {
sockets : [ socket ],
uri : 'sip:4051@sip.group.com',
password : 'password#'
};
var coolPhone = new JsSIP.UA(configuration);
coolPhone.start();
// Register callbacks to desired call events
var eventHandlers = {
'progress': function(e) {
console.log('call is in progress');
},
'failed': function(e) {
console.log('call failed with cause: '+ e.data.cause);
},
'ended': function(e) {
console.log('call ended with cause: '+ e.data.cause);
},
'confirmed': function(e) {
console.log('call confirmed');
}
};
var options = {
'eventHandlers' : eventHandlers,
'mediaConstraints' : { 'audio': true, 'video': true }
};
var session = coolPhone.call('sip:4050@sip.group.com', options);
</script>
</html>
我的服务器分机号是 4051,我正在尝试拨打 4050 我的同事。但是,如果我打开 Chrome 的控制台,我会看到以下错误:
WebSocket connection to 'wss://sip.group.com/' failed: WebSocket opening handshake was canceled