An0*_*d3r 5 javascript asterisk node.js asterisk-ari
所以,我开始玩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
Run Code Online (Sandbox Code Playgroud)
在我的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!!');
});
...
Run Code Online (Sandbox Code Playgroud)
问题是,anon回调永远不会被解雇.我从未见过'HELLLLLLOOOOO !!'
任何人都可以阐明为什么/在什么情况下会发生这种情况?该模块是否存在可能导致此问题的已知错误?
如果您需要有关配置,环境等的更多信息,请与我们联系.
多谢你们
UPDATE
以下评论......我尝试了以下内容:
client.connect(url, username, password)
.then(function(ari) {
console.log('HELLLLLLOOOOO!!');
})
.catch(function(err){
console.log('ERR: ' + err);
});
Run Code Online (Sandbox Code Playgroud)
和
client.connect(url, username, password, function (err, ari) {
if(err) console.log(err);
console.log('HELLLLLLOOOOO!!');
});
Run Code Online (Sandbox Code Playgroud)
没有错误,没有'HELLLLLOOOOOO !!' 在任何一点:-(
更新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"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我现在认为这可能是一个SSL问题?!
您的连接失败(原因如下所述),并且由于 中的问题/即将推出的功能node-ari-client,不会记录失败的连接。
该node-ari-client模块使用Swagger,它期望加载描述 API 的 JSON 模式。在实现中node-ari-client,Swagger 希望在 找到此 JSON 模式%s//%s/ari/api-docs/resources.json。
因此,首先要检查的是您的应用程序中是否存在/可访问:
https://192.168.46.122:8088/ari/api-docs/resources.json
可能有多种原因导致此功能不可用,但最有可能的问题是身份验证。您提到,当您访问您的网址时,系统会“提示您输入用户名和密码”。如果您的 JSON 架构(或需要在没有凭据的情况下访问的任何其他文件)需要进行身份验证,则您将需要重新考虑您的应用程序结构。
目前,如果在Swagger 加载 JSON 架构之前发生连接失败,node-ari-client将会失败且静默。有一个拉请求等待解决此问题并记录错误,但与此同时,您应该解决阻止连接的根本问题。
如果您可以成功访问resources.json,则可能存在访问资源的其他问题。您描述的 URL 正在通过 访问您的服务https,但您的resources.json文件告诉 Swagger 通过常规 http 访问它。为了解决这个问题,你可以尝试:
basePath将Swagger 架构中的更改为使用https:
"basePath": "https://192.168.46.122:8088/ari",
将字段添加protocols到 Swagger 架构中:
"protocols":["http", "https"]
删除 https
这可能是一个不错的选择,可以确定是否https是造成连接问题的原因。只需保持 Swagger 架构完全不变,然后尝试通过 访问/连接到您的服务http。这有什么区别吗?
| 归档时间: |
|
| 查看次数: |
897 次 |
| 最近记录: |