SIP.js 通过 WSS 与 Asterisk 11.20 的连接不起作用

SIP.js 通过 WSS 与 Asterisk 11.20 的连接不起作用

我已成功使用标准非安全 ws:// 将 sip.js 设置为使用 Firefox 43 的 Aterisk 11 服务器。我可以拨打和接听另一个 ff 浏览器/硬电话的电话。但这不适用于最新的 Chrome,即 Chrome 47。我无法获得任何音频(Chrome 没有询问我想使用哪种音频。它总是停留在“获取本地媒体”状态)

sip-0.7.2.min.js:36 Sat Jan 16 2016 15:02:05 GMT-0500 (EST) | sip.invitecontext.mediahandler | acquiring local media

从我读到的有关 chrome 47 的内容来看,https://developers.google.com/web/updates/2015/10/chrome-47-webrtc?hl=en

从 Chrome 47 开始,getUserMedia() 请求仅允许来自安全来源:HTTPS 或 localhost。

因此,我尝试配置 asterisk 和 sipjs 以开始使用安全的 websockets (wss),但 wss 连接出现问题。chrome 控制台输出如下:

sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | configuration parameters after validation:
2016-01-16 14:17:01.816 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · viaHost: "192.0.2.190"
2016-01-16 14:17:01.817 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · uri: sip:[email protected]
2016-01-16 14:17:01.819 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · wsServers: [{"ws_uri":"wss://192.168.10.145:8089/asterisk/ws","sip_uri":"<sip:192.168.10.145:8089;transport=ws;lr>","weight":0,"status":0,"scheme":"WSS"}]
2016-01-16 14:17:01.821 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · password: NOT SHOWN
2016-01-16 14:17:01.822 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · registerExpires: 600
2016-01-16 14:17:01.822 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · register: true
2016-01-16 14:17:01.823 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · registrarServer: sip:192.168.10.145
2016-01-16 14:17:01.823 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · wsServerMaxReconnection: 3
2016-01-16 14:17:01.823 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · wsServerReconnectionTimeout: 4
2016-01-16 14:17:01.823 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · connectionRecoveryMinInterval: 2
2016-01-16 14:17:01.824 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · connectionRecoveryMaxInterval: 30
2016-01-16 14:17:01.824 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · keepAliveInterval: 0
2016-01-16 14:17:01.824 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · extraSupported: []
2016-01-16 14:17:01.824 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · usePreloadedRoute: false
2016-01-16 14:17:01.825 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · userAgentString: "SIP.js/0.7.2"
2016-01-16 14:17:01.825 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · iceCheckingTimeout: 5000
2016-01-16 14:17:01.825 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · noAnswerTimeout: 30000
2016-01-16 14:17:01.826 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · stunServers: ["stun:stun.l.google.com:19302"]
2016-01-16 14:17:01.826 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · turnServers: []
2016-01-16 14:17:01.826 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · traceSip: true
2016-01-16 14:17:01.826 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · hackViaTcp: false
2016-01-16 14:17:01.827 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · hackIpInContact: true
2016-01-16 14:17:01.827 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · hackWssInTransport: true
2016-01-16 14:17:01.827 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · hackAllowUnregisteredOptionTags: false
2016-01-16 14:17:01.828 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · contactTransport: "wss"
2016-01-16 14:17:01.828 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · forceRport: false
2016-01-16 14:17:01.829 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · autostart: true
2016-01-16 14:17:01.829 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · rel100: "none"
2016-01-16 14:17:01.830 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · replaces: "none"
2016-01-16 14:17:01.830 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · mediaHandlerFactory: function (a,c){return new b(a,c)}
2016-01-16 14:17:01.831 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · authenticationFactory: undefined
2016-01-16 14:17:01.831 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · authorizationUser: "1001"
2016-01-16 14:17:01.831 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · displayName: "bobby laptop"
2016-01-16 14:17:01.832 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · instanceId: "4143f767-8b09-4e4f-b39e-dbe70a72605b"
2016-01-16 14:17:01.832 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · sipjsId: "e64e9"
2016-01-16 14:17:01.832 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · hostportParams: "192.168.10.145"
2016-01-16 14:17:01.833 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | · media: undefined
2016-01-16 14:17:01.865 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.ua | user requested startup...
2016-01-16 14:17:01.866 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:01 GMT-0500 (EST) | sip.transport | connecting to WebSocket wss://192.168.10.145:8089/asterisk/ws
2016-01-16 14:17:03.693 sip-0.7.2.min.js:39 WebSocket connection to 'wss://192.168.10.145:8089/asterisk/ws' failed: WebSocket opening handshake was canceled
2016-01-16 14:17:03.701 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:03 GMT-0500 (EST) | sip.transport | WebSocket connection error: {"isTrusted":true}
2016-01-16 14:17:03.704 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:03 GMT-0500 (EST) | sip.transport | WebSocket disconnected (code: 1006)
2016-01-16 14:17:03.705 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:03 GMT-0500 (EST) | sip.transport | WebSocket abrupt disconnection
2016-01-16 14:17:03.705 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:03 GMT-0500 (EST) | sip.ua | transport wss://192.168.10.145:8089/asterisk/ws failed | connection state set to 2
2016-01-16 14:17:03.706 sip-0.7.2.min.js:36 Sat Jan 16 2016 14:17:03 GMT-0500 (EST) | sip.ua | next connection attempt in 2 seconds

从 asterisk CLI 中,我可以看到 https 已启用。

stations-desktop*CLI> http show status 
HTTP Server Status:
Prefix: /asterisk
Server Enabled and Bound to 0.0.0.0:8088

HTTPS Server Enabled and Bound to 0.0.0.0:8089

Enabled URI's:
/asterisk/httpstatus => Asterisk HTTP General Status
/asterisk/phoneprov/... => Asterisk HTTP Phone Provisioning Tool
/asterisk/static/... => Asterisk HTTP Static Delivery
/asterisk/ws => Asterisk HTTP WebSocket

Enabled Redirects:
None.

http配置文件

[general]
enabled=yes
bindaddr=0.0.0.0
bindport=8088
prefix=asterisk
enablestatic=yes
tlsenable=yes
tlsbindaddr=0.0.0.0:8089
tlscertfile=/etc/asterisk/keys/asterisk.pem
tlsprivatekey=/etc/asterisk/keys/asterisk.pem

配置文件

[general]
context=public
allowoverlap=no
udpbindaddr=0.0.0.0
tcpenable=no
tcpbindaddr=0.0.0.0
transport=udp,ws,wss
srvlookup=yes
qualify=yes

tlsenable=yes
tlsbindaddr=0.0.0.0
tlscertfile=/etc/asterisk/keys/asterisk.pem
tlscafile=/etc/asterisk/keys/ca.crt
tlscipher=ALL
tlsclientmethod=tlsv1

[authentication]
[basic-options](!)                ; a template
    dtmfmode=rfc2833
    context=from-office
    type=friend

[webrtc](!)
    type=friend
    host=dynamic
    encryption=yes
    avpf=yes
    icesupport=yes
    context=default
    directmedia=no
    transport=ws,wss
    force_avp=yes
    dtlsenable=yes
    dtlsverify=no
    dtlscertfile=/etc/asterisk/keys/asterisk.pem
    dtlsprivatekey=/etc/asterisk/keys/asterisk.key
    dtlssetup=actpass

[1001](webrtc)
    secret=REDACTED

[1002](webrtc)
    secret=REDACTED

扩展配置文件

[general]
exten => 1002,1,Dial(SIP/1002)
exten => 1003,1,Dial(SIP/1003)
exten => 2000,1,Answer()
same => n,Playback(demo-congrats)
same => n,Hangup()

rtp配置文件

[general]
rtpstart=10000
rtpend=20000
icesupport=true
stunaddr=stun.l.google.com:19302

任何帮助都将受到赞赏!

答案1

我使用的是自签名证书。自签名证书不值得信任。切换到有效的 SSL 证书就可以了。Chrome 47 及更高版本需要这样做。

相关内容