所以,我开始使用 Asterisk Restful Interface (ARI)。
我创建了一个单独的快速应用程序来执行此操作。
我有一个正确配置的 Asterisk 13 实例正在运行。我知道这一点是因为当我进入https://192.168.46.122:8088/ari/sounds
浏览器时,系统会提示我输入用户名和密码,输入时会返回一个有效的 JSON 对象以及预期的数据......
[
{
"id": "conf-now-unmuted",
"text": "The conference is now unmuted.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "vm-nomore",
"text": "No more messages.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "vm-review",
"text": "press 1 to accept this recording press 2 to listen to it press 3 to rerecord your message",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "demo-echodone",
"text": "The echo test has been completed.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
},
{
"id": "confbridge-rest-talk-vol-out",
"text": "...to reset your speaking volume to the default level.",
"formats": [
{
"language": "en",
"format": "gsm"
}
]
}, ...... etc etc
在我的app.js
文件中,我包含了以下代码...
...
var logger = require('morgan');
var client = require('ari-client');
var url = 'https://192.168.46.122:8088/ari/sounds';
var username = 'correct_username';
var password = 'correct_password';
client.connect(url, username, password, function (err, ari) {
console.log('HELLLLLLOOOOO!!');
});
...
问题是匿名回调永远不会被触发。我从来没有看到'HELLLLLLOOOOO!!'
谁能解释为什么/在什么情况下会发生这种情况?模块是否有任何已知的错误可能导致此问题?
如果您需要有关配置、环境等的更多信息,请告诉我。
多谢你们
更新
以下评论......我尝试了以下内容:
client.connect(url, username, password)
.then(function(ari) {
console.log('HELLLLLLOOOOO!!');
})
.catch(function(err){
console.log('ERR: ' + err);
});
和
client.connect(url, username, password, function (err, ari) {
if(err) console.log(err);
console.log('HELLLLLLOOOOO!!');
});
没有错误,也没有'HELLLLLOOOOOOO!!' 在任何时候:-(
更新 2
刚刚访问/ari/api-docs/resources.json
并得到以下回复......所以它看起来像是存在的。
{
"_copyright": "Copyright (C) 2012 - 2013, Digium, Inc.",
"_author": "David M. Lee, II <dlee@digium.com>",
"_svn_revision": "$Revision: 430337 $",
"apiVersion": "1.7.0",
"swaggerVersion": "1.1",
"basePath": "http://192.168.46.122:8088/ari",
"apis": [
{
"path": "/api-docs/asterisk.{format}",
"description": "Asterisk resources"
},
{
"path": "/api-docs/endpoints.{format}",
"description": "Endpoint resources"
},
{
"path": "/api-docs/channels.{format}",
"description": "Channel resources"
},
{
"path": "/api-docs/bridges.{format}",
"description": "Bridge resources"
},
{
"path": "/api-docs/recordings.{format}",
"description": "Recording resources"
},
{
"path": "/api-docs/sounds.{format}",
"description": "Sound resources"
},
{
"path": "/api-docs/playbacks.{format}",
"description": "Playback control resources"
},
{
"path": "/api-docs/deviceStates.{format}",
"description": "Device state resources"
},
{
"path": "/api-docs/mailboxes.{format}",
"description": "Mailboxes resources"
},
{
"path": "/api-docs/events.{format}",
"description": "WebSocket resource"
},
{
"path": "/api-docs/applications.{format}",
"description": "Stasis application resources"
}
]
}
我现在认为这可能是 SSL 问题?!