0

我正在尝试来自星号 ari github 的示例。现在我在 brigde-dial 示例中但有一个问题。当我尝试 javascript 代码时,它会给出以下错误:

usage: node bridge-dial.js endpoint

但 python 工作正常,我可以拨打另一个 pjsip 端点。这是 javascript 示例:

github上的桥拨号Javascript示例

这个是python:

github上的桥拨号Python示例

你能帮我解决问题吗?

顺便说一句,我编写了一个 javascript 代码来将 pjsip 推送到星号。这里是:

var request = require('request');
var json = require('json');

var userName = '5000';



 authUrl = 'http://localhost:8088/ari/asterisk/config/dynamic/res_pjsip/auth/' +userName;

 aorUrl = 'http://localhost:8088/ari/asterisk/config/dynamic/res_pjsip/aor/' +userName;

 endpointUrl = 'http://localhost:8088/ari/asterisk/config/dynamic/res_pjsip/endpoint/' +userName;



 authconfig = {
    'fields': [
      { 'attribute': 'auth_type', 'value': 'userpass' },
      { 'attribute': 'username', 'value': userName },
      { 'attribute': 'password', 'value': 'asterisk' },
      { 'attribute': 'md5_cred', 'value': '' },
      { 'attribute': 'nonce_lifetime', 'value': '32' },


     ]
   };

 aorconfig = {
      'fields': [
         { 'attribute': 'support_path', 'value': 'yes' },
         { 'attribute': 'remove_existing', 'value': 'yes' },
         { 'attribute': 'max_contacts', 'value': '1' },
         { 'attribute': 'default_expiration', 'value': '3600' },
         { 'attribute': 'qualify_timeout', 'value': '3.000000' },
         { 'attribute': 'mailboxes', 'value': '' },
         { 'attribute': 'minimum_expiration', 'value': '60' },
         { 'attribute': 'outbound_proxy', 'value': '' },
         { 'attribute': 'maximum_expiration', 'value': '7200' },
         { 'attribute': 'qualify_frequency', 'value': '0' },
         { 'attribute': 'authenticate_qualify', 'value': 'no' },
         { 'attribute': 'contact', 'value': '' },

     ]
 };

 endpointconfig = {
     'fields': [
         { 'attribute': 'from_user', 'value': userName },
         { 'attribute': 'allow', 'value': '!all,g722,ulaw,alaw' },
         { 'attribute': 'ice_support', 'value': 'yes' },
         { 'attribute': 'force_rport', 'value': 'yes' },
         { 'attribute': 'rewrite_contact', 'value': 'yes' },
         { 'attribute': 'rtp_symmetric', 'value': 'yes' },
         { 'attribute': 'context', 'value': 'default' },
         { 'attribute': 'auth', 'value': userName },
         { 'attribute': 'aors', 'value': userName },
     ]
 };




 var respAuth = { 'auth': {'username':'asterisk', 'password':'asterisk'}, url: authUrl, json: authconfig}


 request.put(respAuth, function(err,res) {
 if(err) {
    console.log ('Received Error');
 }
 else {
       if(res.statusCode == 200) {
         console.log('Successfully Pushed');
         var result = JSON.stringify(res.body, null, 2);
         var finalResult = result.replace(/\\n/gi, '\n');
         console.log(finalResult);

        } else {
         console.log('Object Not Found');

 }
 }

 });

 var respAor = { 'auth': {'username':'asterisk', 'password':'asterisk'}, url: aorUrl, json: aorconfig}

 request.put(respAor, function(err,res) {
 if(err) {
    console.log ('Received Error');
 }
 else {
       if(res.statusCode == 200) {
         console.log('Successfully Pushed');
         var result = JSON.stringify(res.body, null, 2);
         var finalResult = result.replace(/\\n/gi, '\n');
         console.log(finalResult);

        } else {
         console.log('Object Not Found');
 }
 }

 });

 var respEndpoint = { 'auth': {'username':'asterisk',      'password':'asterisk'}, url: endpointUrl, json: endpointconfig}

 request.put(respEndpoint, function(err,res) {
 if(err) {
    console.log ('Received Error');
 }else {
       if(res.statusCode == 200) {
         console.log('Successfully Pushed');
         var result = JSON.stringify(res.body, null, 2);
         var finalResult = result.replace(/\\n/gi, '\n');
         console.log(finalResult);

        } else {
         console.log('Object Not Found');
 }
 }

 });
4

1 回答 1

0

如果有人偶然发现同样的问题,我通过这样做解决了这个问题:

我删除了;

if (!process.argv[2]) { console.error('usage: node bridge-dial.js endpoint'); process.exit(1); }

并更改了下面的代码;

dialed.originate(
  {endpoint: process.argv[2], app: 'bridge-dial', appArgs: 'dialed'},

                             |
                             |
                             V


dialed.originate(
  {endpoint: channel.dialplan.exten, app: 'bridge-dial', appArgs: 'dialed'},
于 2017-10-20T13:48:42.560 回答