So, I started playing with Asterisk Restful Interface (ARI).
For this, I created a separate express application.
I have a properly configured launch instance of Asterisk 13. I know this because when I go to https://192.168.46.122:8088/ari/sounds in my browser, I am asked to enter a username and password, which when I enter it returns return JSON object with expected data ...
[ { "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
In my app.js file app.js I have included the following code ...
... 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!!'); }); ...
The problem is that anon callback never starts. I never see "HELLLLLOOOOOO !!"
Can someone shed some light on why / under what circumstances this can happen? Are there any known errors with the module that may be causing this?
Please let me know if you need more information about configuration, environment, etc.
Thanks guys,
UPDATE
The following comments below ... I have tried the following:
client.connect(url, username, password) .then(function(ari) { console.log('HELLLLLLOOOOO!!'); }) .catch(function(err){ console.log('ERR: ' + err); });
and
client.connect(url, username, password, function (err, ari) { if(err) console.log(err); console.log('HELLLLLLOOOOO!!'); });
There is no error and no "HELLLLLOOOOOO !!" at any point: - (
UPDATE 2
Just visited /ari/api-docs/resources.json and got the following answer ... so that it looks like it is present.
{ "_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" } ] }
Now I think it could be an SSL problem ?!