我非常感谢你对这个问题的帮助。我正在使用jsSIP用户代理运行一个非常基本的JS脚本,该代理使用本地Asterisk服务器进行语音呼叫。一切都在私人网络上,我没有从Asterisk CLI收到任何警告或错误,但当我拨打传统的SIP电话或测试扩展时,任何一方都没有音频,尽管那里铃声响起,电话可以回答而且它们永远不会掉线。我的Asterisk 12是用SRTP和pjproject编译的。
我在Asterisk WebRTC Wiki(https://wiki.asterisk.org/wiki/display/AST/Asterisk+WebRTC+Support)上阅读了这个:“从Asterisk 12开始,你需要安装pjproject库,否则你很可能在你的WebRTC调用中没有音频而没有警告!“ 我正确地安装了它并为Asterisk编译选择了它,但是我想知道我做错了,我怎么能检查它...
这些是我的Asterisk文件:
http.conf
[general]
enabled=yes;
bindaddr=0.0.0.0;
bindport=8088;
prefix=asterisk;
tlsenable=yes;
tlsbindaddr=0.0.0.0:8089;
tlscertfile=/etc/asterisk/keys/asterisk.pem;
tlsprivatekey=/etc/asterisk/keys/asterisk.pem;
rtp.conf
[general]
rtpstart=10000;
rtpend=20000;
icesupport=true;
stunaddr=stun.l.google.com:19302;
sip.conf
[general]
allow=ulaw
allow=alaw
allow=gsm
[1000] ;legacy softphone (zoiper)
secret=******
type=friend
host=dynamic
dtmfmode=rfc2833
disallow=all
allow=ulaw
allow=alaw
context=myContext
[1001] ;jsSIP User Agent
type=friend
username=1001
host=dynamic
secret=******
encryption=yes
avpf=yes
icesupport=yes
directmedia=no
transport=udp,ws
force_avp=yes
dtlsenable=yes
dtlsverify=no
disallow=all
allow=ilbc
allow=g729
allow=gsm
allow=g723
allow=ulaw
dtlscertfile=/etc/asterisk/keys/asterisk.pem
dtlsprivatekey=/etc/asterisk/keys/asterisk.pem
dtlssetup=actpass
context=myContext
这是我的jsSIP客户端的JS脚本:
var ua = null;
var session = null;
var myMultimedia = document.getElementById('myMultimedia');
var theirMultimedia = document.getElementById('theirMultimedia');
var local_stream = null;
var remote_stream = null;
function registerUA() {
var configuration = {
uri: "sip:1001@192.168.0.4",
password: ******,
ws_servers: "ws://192.168.0.4:8088/asterisk/ws",
display_name: "UA WebRTC",
authorization_user: null,
register: null,
register_expires: null,
no_answer_timeout: null,
trace_sip: true,
stun_servers: null,
turn_servers: null,
use_preloaded_route: null,
connection_recovery_min_interval: null,
connection_recovery_max_interval: null,
hack_via_tcp: null,
hack_ip_in_contact: true
};
ua = new JsSIP.UA(configuration);
ua.start();
}
function callAsterisk() {
var numTel = document.getElementById('numTel').value;
console.log(numTel);
var eventH = {
'progress': function (e) { },
'failed': function (e) { },
'ended': function (e) { },
'confirmed': function (e) {
local_stream = session.connection.getLocalStreams()[0];
console.log(local_stream); //If i print this variable I do get a media stream
myMultimedia = JsSIP.rtcninja.attachMediaStream(myMultimedia, local_stream);
},
'addstream': function (e) {
remote_stream = e.stream;
console.log(remote_stream); //If i print this variable I do get a media stream
theirMultimedia = JsSIP.rtcninja.attachMediaStream(theirMultimedia, remote_stream);
}
};
var options = {
'eventHandlers': eventH,
'mediaConstraints': {
'audio': true,
'video': false
}
};
session = ua.call('sip:' + numTel + '@192.168.0.4', options);
}
这里我留下jsSIP的调试,显示与订阅我的UA和拨打测试扩展200('hello-world'录音)相关的SIP消息:
1。订阅:
JsSIP:UA configuration parameters after validation: +0ms
JsSIP:UA - via_host: "192.0.2.177" +8ms
JsSIP:UA - password: NOT SHOWN +7ms
JsSIP:UA - register_expires: 600 +6ms
JsSIP:UA - register: true +5ms
JsSIP:UA - registrar_server: sip:192.168.0.4 +6ms
JsSIP:UA - ws_server_max_reconnection: 3 +5ms
JsSIP:UA - ws_server_reconnection_timeout: 4 +5ms
JsSIP:UA - connection_recovery_min_interval: 2 +5ms
JsSIP:UA - connection_recovery_max_interval: 30 +6ms
JsSIP:UA - use_preloaded_route: false +8ms
JsSIP:UA - no_answer_timeout: 60000 +6ms
JsSIP:UA - session_timers: true +5ms
JsSIP:UA - hack_via_tcp: false +4ms
JsSIP:UA - hack_via_ws: false +5ms
JsSIP:UA - hack_ip_in_contact: true +5ms
JsSIP:UA - node_websocket_options: {} +5ms
JsSIP:UA - uri: sip:1001@192.168.0.4 +6ms
JsSIP:UA - ws_servers: [{"ws_uri":"ws://192.168.0.4:8088/asterisk/ws","sip_uri":"<sip:192.168.0.4:8088;transport=ws;lr>","weight":0,"status":0,"scheme":"WS"}] +5ms
JsSIP:UA - display_name: "UA WebRTC" +6ms
JsSIP:UA - instance_id: "b1a09033-7533-47a8-a039-1a6760b2af84" +5ms
JsSIP:UA - jssip_id: "6gejr" +5ms
JsSIP:UA - hostport_params: "192.168.0.4" +4ms
JsSIP:UA - authorization_user: "1001" +5ms
JsSIP:UA start() +6ms
JsSIP:Transport connecting to WebSocket ws://192.168.0.4:8088/asterisk/ws +6ms
JsSIP:Transport WebSocket ws://192.168.0.4:8088/asterisk/ws connected +150ms
JsSIP:Transport
sending WebSocket message:
REGISTER sip:192.168.0.4 SIP/2.0
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK9352120
Max-Forwards: 69
To: <sip:1001@192.168.0.4>
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=f8m06houfb
Call-ID: liamoji649fhds9jtdajfi
CSeq: 1 REGISTER
Contact: <sip:grd0bbtt@192.0.2.177;transport=ws>;+sip.ice;reg-id=1;+sip.instance="<urn:uuid:b1a09033-7533-47a8-a039-1a6760b2af84>";expires=600
Expires: 600
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER
Supported: path,gruu,outbound
User-Agent: JsSIP 0.7.4
Content-Length: 0
+15ms
jssip-0.7.4.js (line 22459)
JsSIP:Transport
received WebSocket text message:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK9352120;received=192.168.0.4
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=f8m06houfb
To: <sip:1001@192.168.0.4>;tag=as2235a73d
Call-ID: liamoji649fhds9jtdajfi
CSeq: 1 REGISTER
Server: Asterisk PBX 12.8.2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="0f6c6c26"
Content-Length: 0
+30ms
jssip-0.7.4.js (line 22459)
JsSIP:Transport
sending WebSocket message:
REGISTER sip:192.168.0.4 SIP/2.0
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK1900716
Max-Forwards: 69
To: <sip:1001@192.168.0.4>
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=f8m06houfb
Call-ID: liamoji649fhds9jtdajfi
CSeq: 2 REGISTER
Authorization: Digest algorithm=MD5, username="1001", realm="asterisk", nonce="0f6c6c26", uri="sip:192.168.0.4", response="bed4984f5fc3c21f3854dccdb30a74b2"
Contact: <sip:grd0bbtt@192.0.2.177;transport=ws>;+sip.ice;reg-id=1;+sip.instance="<urn:uuid:b1a09033-7533-47a8-a039-1a6760b2af84>";expires=600
Expires: 600
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER
Supported: path,gruu,outbound
User-Agent: JsSIP 0.7.4
Content-Length: 0
+32ms
jssip-0.7.4.js (line 22459)
JsSIP:Transport
received WebSocket text message:
SIP/2.0 200 OK
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK1900716;received=192.168.0.4
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=f8m06houfb
To: <sip:1001@192.168.0.4>;tag=as2235a73d
Call-ID: liamoji649fhds9jtdajfi
CSeq: 2 REGISTER
Server: Asterisk PBX 12.8.2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Expires: 600
Contact: <sip:grd0bbtt@192.0.2.177;transport=ws>;expires=600
Date: Mon, 24 Aug 2015 14:15:52 GMT
Content-Length: 0
2。拨打分机号200(hello-world):
JsSIP:UA call() +3m
JsSIP:RTCSession new +10ms
JsSIP:RTCSession connect() +10ms
JsSIP:RTCSession newRTCSession +200ms
JsSIP:RTCSession session connecting +1s
JsSIP:RTCSession createLocalDescription() +8ms
JsSIP:Transport
sending WebSocket message:
INVITE sip:200@192.168.0.4 SIP/2.0
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK2696832
Max-Forwards: 69
To: <sip:200@192.168.0.4>
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=9q1k7ijiab
Call-ID: 6gejrmupvj5asi2fdhv8
CSeq: 9260 INVITE
Contact: <sip:grd0bbtt@192.0.2.177;transport=ws;ob>
Content-Type: application/sdp
Session-Expires: 90
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER
Supported: timer,ice,replaces,outbound
User-Agent: JsSIP 0.7.4
Content-Length: 936
v=0
o=mozilla...THIS_IS_SDPARTA-40.0 4294967295 0 IN IP4 0.0.0.0
s=-
t=0 0
a=sendrecv
a=fingerprint:sha-256 2F:5D:E3:B3:9B:9C:8E:00:AF:81:CC:E8:39:CA:05:CF:40:D1:66:11:91:3A:F1:A2:6D:78:D5:51:5F:22:96:AC
a=group:BUNDLE sdparta_0
a=ice-options:trickle
a=msid-semantic:WMS *
m=audio 35823 RTP/SAVPF 109 9 0 8
c=IN IP4 192.168.0.4
a=candidate:0 1 UDP 2122252543 192.168.0.4 35823 typ host
a=candidate:0 2 UDP 2122252542 192.168.0.4 35135 typ host
a=sendrecv
a=end-of-candidates
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=ice-pwd:516e745ffd8bf121177f0b7680506018
a=ice-ufrag:37f2205c
a=mid:sdparta_0
a=msid:{aa42a325-b228-4ff3-b52f-de1f1288836e} {7b2300a8-f4ea-4b74-bbfa-ac5c4835b3c8}
a=rtcp:35135 IN IP4 192.168.0.4
a=rtcp-mux
a=rtpmap:109 opus/48000/2
a=rtpmap:9 G722/8000/1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=setup:actpass
a=ssrc:1479786588 cname:{0dbce354-bdf6-4ee7-acb0-e4f12c501e04}
+70ms
JsSIP:Transport
received WebSocket text message:
SIP/2.0 401 Unauthorized
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK2696832;received=192.168.0.4
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=9q1k7ijiab
To: <sip:200@192.168.0.4>;tag=as34ac1926
Call-ID: 6gejrmupvj5asi2fdhv8
CSeq: 9260 INVITE
Server: Asterisk PBX 12.8.2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="3d67a76d"
Content-Length: 0
+43ms
JsSIP:Transport
sending WebSocket message:
ACK sip:200@192.168.0.4 SIP/2.0
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK2696832
To: <sip:200@192.168.0.4>;tag=as34ac1926
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=9q1k7ijiab
Call-ID: 6gejrmupvj5asi2fdhv8
CSeq: 9260 ACK
Content-Length: 0
+40ms
JsSIP:Transport
sending WebSocket message:
INVITE sip:200@192.168.0.4 SIP/2.0
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK3632996
Max-Forwards: 69
To: <sip:200@192.168.0.4>
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=9q1k7ijiab
Call-ID: 6gejrmupvj5asi2fdhv8
CSeq: 9261 INVITE
Authorization: Digest algorithm=MD5, username="1001", realm="asterisk", nonce="3d67a76d", uri="sip:200@192.168.0.4", response="abff34d15fffc9b5baaadeab85d770c9"
Contact: <sip:grd0bbtt@192.0.2.177;transport=ws;ob>
Content-Type: application/sdp
Session-Expires: 90
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER
Supported: timer,ice,replaces,outbound
User-Agent: JsSIP 0.7.4
Content-Length: 936
v=0
o=mozilla...THIS_IS_SDPARTA-40.0 4294967295 0 IN IP4 0.0.0.0
s=-
t=0 0
a=sendrecv
a=fingerprint:sha-256 2F:5D:E3:B3:9B:9C:8E:00:AF:81:CC:E8:39:CA:05:CF:40:D1:66:11:91:3A:F1:A2:6D:78:D5:51:5F:22:96:AC
a=group:BUNDLE sdparta_0
a=ice-options:trickle
a=msid-semantic:WMS *
m=audio 35823 RTP/SAVPF 109 9 0 8
c=IN IP4 192.168.0.4
a=candidate:0 1 UDP 2122252543 192.168.0.4 35823 typ host
a=candidate:0 2 UDP 2122252542 192.168.0.4 35135 typ host
a=sendrecv
a=end-of-candidates
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=ice-pwd:516e745ffd8bf121177f0b7680506018
a=ice-ufrag:37f2205c
a=mid:sdparta_0
a=msid:{aa42a325-b228-4ff3-b52f-de1f1288836e} {7b2300a8-f4ea-4b74-bbfa-ac5c4835b3c8}
a=rtcp:35135 IN IP4 192.168.0.4
a=rtcp-mux
a=rtpmap:109 opus/48000/2
a=rtpmap:9 G722/8000/1
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=setup:actpass
a=ssrc:1479786588 cname:{0dbce354-bdf6-4ee7-acb0-e4f12c501e04}
+18ms
JsSIP:InviteClientTransaction Timer D expired for transaction z9hG4bK2696832 +44ms
JsSIP:Transport
received WebSocket text message:
SIP/2.0 100 Trying
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK3632996;received=192.168.0.4
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=9q1k7ijiab
To: <sip:200@192.168.0.4>
Call-ID: 6gejrmupvj5asi2fdhv8
CSeq: 9261 INVITE
Server: Asterisk PBX 12.8.2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Session-Expires: 90;refresher=uas
Contact: <sip:200@192.168.0.4:5060;transport=WS>
Content-Length: 0
+116ms
JsSIP:RTCSession receiveInviteResponse() +31ms
JsSIP:Transport
received WebSocket text message:
SIP/2.0 200 OK
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK3632996;received=192.168.0.4
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=9q1k7ijiab
To: <sip:200@192.168.0.4>;tag=as2a14b282
Call-ID: 6gejrmupvj5asi2fdhv8
CSeq: 9261 INVITE
Server: Asterisk PBX 12.8.2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Session-Expires: 90;refresher=uas
Contact: <sip:200@192.168.0.4:5060;transport=WS>
Content-Type: application/sdp
Require: timer
Content-Length: 774
v=0
o=root 1590611571 1590611571 IN IP4 192.168.0.4
s=Asterisk PBX 12.8.2
c=IN IP4 192.168.0.4
t=0 0
m=audio 19864 RTP/SAVPF 0
a=rtpmap:0 PCMU/8000
a=ptime:20
a=maxptime:150
a=ice-ufrag:00b9259c164316017df96bd7099a0b59
a=ice-pwd:3eac7a773d965d021529752477b9278e
a=candidate:Hc0a80004 1 UDP 2130706431 192.168.0.4 19864 typ host
a=candidate:Sbdd9418e 1 UDP 1694498815 189.217.65.142 35710 typ srflx raddr 192.168.0.4 rport 19864
a=candidate:Hc0a80004 2 UDP 2130706430 192.168.0.4 19865 typ host
a=candidate:Sbdd9418e 2 UDP 1694498814 189.217.65.142 46555 typ srflx raddr 192.168.0.4 rport 19865
a=connection:new
a=setup:active
a=fingerprint:SHA-256 E2:B9:77:44:04:96:8D:D9:EA:67:B9:E0:6E:93:49:08:5B:33:53:7D:DD:51:5A:1B:0F:7D:45:CA:BD:F9:CE:BA
a=sendrecv
+8ms
JsSIP:RTCSession receiveInviteResponse() +21ms
JsSIP:Dialog new UAC dialog created with status CONFIRMED +9ms
JsSIP:RTCSession session accepted +29ms
JsSIP:RTCSession sendRequest() +10ms
JsSIP:RTCSession:Request new | ACK +11ms
JsSIP:Transport
sending WebSocket message:
ACK sip:200@192.168.0.4:5060;transport=ws SIP/2.0
Via: SIP/2.0/WS 192.0.2.177;branch=z9hG4bK5815096
Max-Forwards: 69
To: <sip:200@192.168.0.4>;tag=as2a14b282
From: "UA WebRTC" <sip:1001@192.168.0.4>;tag=9q1k7ijiab
Call-ID: 6gejrmupvj5asi2fdhv8
CSeq: 9261 ACK
Allow: INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER
Supported: outbound
User-Agent: JsSIP 0.7.4
Content-Length: 0
+18ms
JsSIP:RTCSession session confirmed +11ms
LocalMediaStream { id="{aa42a325-b228-4ff3-b52f-de1f1288836e}", currentTime=0.300375, stop=stop(), more...}//printing of local stream
miScript.js (line 69)
CALL CONFIRMED
miScript.js (line 70)
element is null
jssip-0.7.4.js (line 22924)
MediaStream { id="{38caf558-e986-4c52-b9cd-4abe5384051e}", currentTime=0.0309375, getAudioTracks=getAudioTracks(), more...}
//printing of remote stream
miScript.js (line 77)
REMOTE STREAM RECEIVED
miScript.js (line 78)
TypeError: element is null
jssip-0.7.4.js (line 22924, col 17)
JsSIP:Transport
received WebSocket text message:
BYE sip:grd0bbtt@192.0.2.177;transport=ws;ob SIP/2.0
Via: SIP/2.0/WS 192.168.0.4:5060;branch=z9hG4bK4a805194
Max-Forwards: 70
From: <sip:200@192.168.0.4>;tag=as2a14b282
To: "UA WebRTC" <sip:1001@192.168.0.4>;tag=9q1k7ijiab
Call-ID: 6gejrmupvj5asi2fdhv8
CSeq: 102 BYE
User-Agent: Asterisk PBX 12.8.2
Proxy-Authorization: Digest username="1001", realm="asterisk", algorithm=MD5, uri="sip:192.168.0.4", nonce="3d67a76d", response="4ff114fe1b3b95781c646407da538133"
X-Asterisk-HangupCause: Normal Clearing
X-Asterisk-HangupCauseCode: 16
Content-Length: 0
+2s
JsSIP:RTCSession receiveRequest() +22ms
JsSIP:Transport
sending WebSocket message:
SIP/2.0 200 OK
Via: SIP/2.0/WS 192.168.0.4:5060;branch=z9hG4bK4a805194
To: "UA WebRTC" <sip:1001@192.168.0.4>;tag=9q1k7ijiab
From: <sip:200@192.168.0.4>;tag=as2a14b282
Call-ID: 6gejrmupvj5asi2fdhv8
CSeq: 102 BYE
Supported: outbound
Content-Length: 0
+12ms
JsSIP:RTCSession session ended +12ms
JsSIP:RTCSession close() +8ms
JsSIP:RTCSession close() | closing local MediaStream +12ms
JsSIP:Dialog dialog 6gejrmupvj5asi2fdhv89q1k7ijiabas2a14b282 deleted +11ms
JsSIP:NonInviteServerTransaction Timer J expired for transaction z9hG4bK4a805194 +29ms
TypeError: e.data is undefined
miScript.js (line 65, col 12)
最后,这就是Asterisk CLI所说的: 当我订阅时:
== WebSocket connection from '192.168.0.4:55061' for protocol 'sip' accepted using version '13'
-- Registered SIP '1001' at 192.168.0.4:55061
当我致电:
== Using SIP RTP CoS mark 5
-- Executing [200@myContext:1] Answer("SIP/1001-00000005", "") in new stack
-- Executing [200@myContext:2] Playback("SIP/1001-00000005", "hello-world") in new stack
Sent RTP packet to 192.168.0.4:51805 (via ICE) (type 00, seq 019963, ts 000160, len 000160)
-- <SIP/1001-00000005> Playing 'hello-world.gsm' (language 'en')
Sent RTP packet to 192.168.0.4:51805 (via ICE) (type 00, seq 019964, ts 000320, len 000160)
我有没有想念任何明显的东西?提前致谢:D