我正在尝试从星号ari github.Right现在我在brigde-dial示例,但有一个问题。当我尝试javascript代码时,它给出以下错误:
usage: node bridge-dial.js endpoint
但python工作正常,我可以拨打另一个pjsip端点。这个是javascript示例:
Bridge-dial Javascript example on github
这个是python:
Bridge-dial Python example on github
你能帮我解决问题吗?
顺便说一下,我编写了一个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');
}
}
});
答案 0 :(得分: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'},