节点ARI客户端| 连接方法不启动callback?

所以,我已经开始玩星号Restful接口(ARI)。

我创build了一个单独的快速应用程序来做到这一点。

我有一个正确configuration的Asterisk 13运行的实例。 我知道这是因为当我在浏览器中访问https://192.168.46.122:8088/ari/sounds时,系统提示input用户名和密码,input时返回一个有效的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!!'); }); ... 

问题在于,匿名callback永远不会被解雇。 我从来没有看到'HELLLLLLOOOOO !!'

任何人都可以解释为什么/在什么情况下会发生这种情况? 是否有任何已知的错误,可能导致这个模块?

请让我知道如果你需要进一步的信息关于configuration,环境等

多谢你们

UPDATE

以下评论…我已经尝试了以下内容:

 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!!'); }); 

没有错误,也没有'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" } ] } 

我现在认为这可能是一个SSL问题?!

您的连接失败(出于下面列出的原因),并且由于node-ari-client中的问题/即将到来的function,失败的连接不会被logging。

node-ari-client模块使用Swagger ,该Swagger希望加载描述API的JSON模式。 在node-ari-client实现中,Swagger希望在%s//%s/ari/api-docs/resources.jsonfind这个JSON模式。

所以,首先要检查的是在应用程序中是否存在/可访问:

https://192.168.46.122:8088/ari/api-docs/resources.json

可能有几个原因,为什么这不可用,但最有可能的问题是身份validation。 你提到,当访问你的url时,你会被提示input用户名和密码 。 如果您的JSON模式(或任何其他需要无需凭据访问的文件)在身份validation之后,您将需要重新考虑您的应用程序结构。

目前,如果 Swagger加载JSON模式之前发生连接失败,那么node-ari-client将自动失败。 有一个合并请求等待解决这个问题,并logging错误,但在此期间,你应该解决阻止连接的基本问题。

如果您可以成功访问resources.json ,则访问resources.json可能还存在其他问题。 您所描述的URL是通过https访问您的服务,但您的resources.json文件告诉Swagger通过常规的http访问它。 要处理这个问题,你可以尝试:

更改Swagger模式中的basePath以使用https

"basePath": "https://192.168.46.122:8088/ari",

protocols字段添加到Swagger架构中:
"protocols":["http", "https"]

删除https
这可能是一个很好的select,以便发现https是否是连接问题的原因。 只需保持Swagger架构完全一样,然后尝试通过http访问/连接到您的服务。 这是否有所作为?