我使用freeswitch作为sip服务器,也使用freeswitch文件夹中的pem (/usr/local/freeswitch/certs)。
客户端部件上的--我使用SIP.js客户端--看起来像:
<script src="https://rawgit.com/onsip/SIP.js/0.8.0/dist/sip-0.8.0.js"></script>
<!--script src="sip-0.12.0.js"></script-->
<video id="remoteVideo"></video>
<video id="localVideo" muted="muted"></video>
<script>
var userAgent = new SIP.UA({
uri: '1002@192.168.0.100',
wsServers: ['wss://192.168.0.100:7443'],
authorizationUser: '1002',
password: '1234',
});
userAgent.on("connected", function() {
console.log("Connected $$$$$$$$$$$$$$$$$$$$$$$$");
});
userAgent.on('invite', function (session) {
session.accept({
media: {
render: {
remote: {
video: document.getElementById('remoteVideo')
},
local: {
video: document.getElementById('localVideo')
}
}
}
});
});
</script>浏览器(chrome)中的错误日志:
sip-0.8.0.js:11540 WebSocket connection to 'wss://192.168.0.100:7443/' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID
connect @ sip-0.8.0.js:11540
Transport @ sip-0.8.0.js:11428
(anonymous) @ sip-0.8.0.js:7798
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.transport | WebSocket connection error:
LoggerFactory.print @ sip-0.8.0.js:746
LoggerFactory.(anonymous function) @ sip-0.8.0.js:763
Logger.(anonymous function) @ sip-0.8.0.js:757
onError @ sip-0.8.0.js:11725
ws.onerror @ sip-0.8.0.js:11565
error (async)
connect @ sip-0.8.0.js:11564
Transport @ sip-0.8.0.js:11428
(anonymous) @ sip-0.8.0.js:7798
setTimeout (async)
Timers.(anonymous function) @ sip-0.8.0.js:1446
UA.recoverTransport @ sip-0.8.0.js:7795
UA.onTransportError @ sip-0.8.0.js:7452
onClose @ sip-0.8.0.js:11633
ws.onclose @ sip-0.8.0.js:11552
sip-0.8.0.js:746 Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}
LoggerFactory.print @ sip-0.8.0.js:746
LoggerFactory.(anonymous function) @ sip-0.8.0.js:763
Logger.(anonymous function) @ sip-0.8.0.js:757
onError @ sip-0.8.0.js:11726
ws.onerror @ sip-0.8.0.js:11565
error (async)
connect @ sip-0.8.0.js:11564
Transport @ sip-0.8.0.js:11428
(anonymous) @ sip-0.8.0.js:7798
setTimeout (async)
Timers.(anonymous function) @ sip-0.8.0.js:1446
UA.recoverTransport @ sip-0.8.0.js:7795
UA.onTransportError @ sip-0.8.0.js:7452
onClose @ sip-0.8.0.js:11633
ws.onclose @ sip-0.8.0.js:11552
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.transport | WebSocket disconnected (code: 1006)
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.transport | WebSocket abrupt disconnection
LoggerFactory.print @ sip-0.8.0.js:746
LoggerFactory.(anonymous function) @ sip-0.8.0.js:763
Logger.(anonymous function) @ sip-0.8.0.js:757
onClose @ sip-0.8.0.js:11614
ws.onclose @ sip-0.8.0.js:11552
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.ua | transport wss://192.168.0.100:7443 failed | connection state set to 2
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.ua | time for next connection attempt exceeds connectionRecoveryMaxInterval, resetting counter
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:42 GMT+0100 (Central European Standard Time) | sip.ua | next connection attempt in 2 seconds
sip-0.8.0.js:746 Thu Jan 03 2019 11:10:44 GMT+0100 (Central European Standard Time) | sip.transport | connecting to WebSocket wss://192.168.0.100:7443登录在localhost env中运行的freeswitch服务器:
tport.c:2753 tport_wakeup_pri() tport_wakeup_pri(0x7f8780e28b20): events IN
tport.c:862 tport_alloc_secondary() tport_alloc_secondary(0x7f8780e28b20): new secondary tport 0x7f878193c200
tport.c:2294 tport_set_secondary_timer() tport(0x7f878193c200): set timer at 4998 ms because keepalive
tport.c:2644 tport_accept() tport_accept(0x7f878193c200): new connection from wss/192.168.0.100:56317/sips
tport.c:2777 tport_wakeup() tport_wakeup(0x7f878193c200): events IN
tport.c:2868 tport_recv_event() tport_recv_event(0x7f878193c200)
tport_type_ws.c:232 tport_recv_stream_ws() tport_recv_stream_ws(0x7f878193c200): su_getmsgsize(): Host is down (64) N=-1
tport.c:2159 tport_shutdown0() tport_shutdown0(0x7f878193c200, 2)
tport.c:2092 tport_close() tport_close(0x7f878193c200): wss/192.168.0.100:56317/sips
tport.c:2265 tport_set_secondary_timer() tport(0x7f878193c200): set timer at 0 ms because zap
tport_type_ws.c:531 tport_ws_deinit_secondary() 0x7f878193c200 destroy wss transport 0x7f878193c3f0.发布于 2019-01-09 08:35:37
该错误清楚地表明它是证书颁发。
sip-0.8.0.js:11540 WebSocket连接到'wss://192.168.0.100:7443/‘failed:>连接建立中的错误:WebSocket 我使用freeswitch作为sip服务器,也使用freeswitch文件夹中的pem (/usr/local/freeswitch/certs)
Freeswitch提供的证书是一个自签名证书,不是为您的服务器地址192.168.0.100生成的。您可以尝试使用openssl生成一个
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout 192.168.0.100密钥-out 192.168.0.100 req -extensions san -config <(echo "req";echo distinguished_name=req;echo "san";echo subjectAltName=DNS:192.168.0.100,IP:192.168.0.100) -subj /CN=192.168.0.100
使用wss.pem使用https://freeswitch.org/confluence/display/FREESWITCH/WebRTC#WebRTC-InstallCertificates
如果您获得认证权限错误,在浏览器(如Chrome )上使用webrtc的自签名证书,最好生成一个带有域名的有效SSL证书并使用它。
致以问候!
https://stackoverflow.com/questions/54020223
复制相似问题