Ошибка javascript набора номера моста через звездочку
Я пробую примеры из звездочки ari github. Сейчас я нахожусь на примере brigde-dial, но есть проблема. Когда я пробую код javascript, он выдает следующую ошибку:
usage: node bridge-dial.js endpoint
но python работает нормально, и я могу набрать другую конечную точку pjsip. Это пример javascript:
Пример Javascript для бридж-набора на github
и это Python:
Пример Python для бридж-набора на 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');
}
}
});
1 ответ
Решение
Если кто-то сталкивается с той же проблемой, я решил эту проблему, выполнив это:
Я удалил;
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'},