Asterisk sip.js远程调用

时间:2014-08-03 11:24:59

标签: javascript sip asterisk webrtc

我正在使用Asterisk 12和sip.js。我试图从zoiper(安卓手机)调用chrome浏览器

我的梨是

[6004]
context=default
secret=6004
type=friend
host=dynamic


[1060] ; This will be WebRTC client
type=friend
username=1060 ; The Auth user for SIP.js
host=dynamic ; Allows any host to register
secret=1060 ; The SIP Password for SIP.js
encryption=yes ; Tell Asterisk to use encryption for this peer
avpf=yes ; Tell Asterisk to use AVPF for this peer
icesupport=yes ; Tell Asterisk to use ICE for this peer
context=default ; Tell Asterisk which context to use when this peer is dialing
directmedia=no ; Asterisk will relay media for this peer
transport=udp,ws ; Asterisk will allow this peer to register on UDP or WebSockets
force_avp=yes ; Force Asterisk to use avp. Introduced in Asterisk 11.11
videosupport=no
nat=force_rport,comedia

和我的JS代码是

   var session;
    var mediaStream;
    var audio = new Audio('ring.mp3');
    var config = {
        // Replace this IP address with your Asterisk IP address
        uri: 'sip:1060@XXX:9091',
        // Replace this IP address with your Asterisk IP address,
        // and replace the port with your Asterisk port from the http.conf file
        ws_servers: 'ws://XXX:9092/ws',
        // Replace this with the username from your sip.conf file
        authorizationUser: '1060',
        // Replace this with the password from your sip.conf file
        password: '1060',
        // HackIpInContact for Asterisk
        hackIpInContact: true
    };

    var ua = new SIP.UA(config);

    ua.on('invite', function(incomingSession) {
        session = incomingSession;
        audio.play();
        prepareToanswer();
    });

我可以获得邀请但是当我接受它时,我无法获得音频流。有人能帮助我吗?

1 个答案:

答案 0 :(得分:3)

听起来您的DTLS证书可能无法正确设置。

    mkdir /etc/asterisk/keys
    cd /usr/local/src/asterisk*/contrib/scripts.
   ./ast_tls_cert -C pbx.mycompany.com -O "My Super Company" -d /etc/asterisk/keys.

将pbx.mycompany.com替换为您的Asterisk框的IP地址。

来源:http://sipjs.com/guides/server-configuration/asterisk/