Quindi, ho iniziato a giocare con l'interfaccia Restus Asterisk (ARI).Client ARI nodo | Il metodo Connect non attiva la richiamata?
Ho creato un'app Express separata per farlo.
Ho un'istanza configurata correttamente di Asterisk 13 in esecuzione. Lo so perché quando vado a https://192.168.46.122:8088/ari/sounds
nel mio browser, sono richiamato per un username e una password, che una volta entrato, restituisce un oggetto JSON valida indietro con i dati previsti ...
[
{
"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
Nel mio file app.js
Ho incluso il seguente codice ...
...
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!!');
});
...
Il problema è che la richiamata anon non viene mai attivata. Non vedo mai 'HELLLLLLOOOOO !!'
Qualcuno può fare luce sul perché/in quali circostanze questo potrebbe accadere? Ci sono dei bug noti con il modulo che potrebbero causare questo?
Per favore fatemi sapere se avete bisogno di ulteriori informazioni su config, ambiente, ecc
Grazie ragazzi
UPDATE
Seguendo commenti qui sotto ... Ho provato quanto segue:
client.connect(url, username, password)
.then(function(ari) {
console.log('HELLLLLLOOOOO!!');
})
.catch(function(err){
console.log('ERR: ' + err);
});
E
client.connect(url, username, password, function (err, ari) {
if(err) console.log(err);
console.log('HELLLLLLOOOOO!!');
});
Nessun errore e nessun 'HELLLLLOOOOOO !!' in qualsiasi momento :-(
UPDATE 2
appena visitato /ari/api-docs/resources.json
ed ha ottenuto la seguente risposta ... così sembra che esso è presente.
{
"_copyright": "Copyright (C) 2012 - 2013, Digium, Inc.",
"_author": "David M. Lee, II <[email protected]>",
"_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"
}
]
}
Ora sto pensando potrebbe essere un problema SSL ?!
puoi provare questo 'client.connect (url, username, password) .then (function (ari) {}). Catch (function (err) {console.log (err);});' aiuterà per vedere quale è l'errore –
In linea con Khaled qui, puoi vedere se stai ricevendo un errore nel callback. Sopra console.log, scrivi 'if (err) console.error (err);' –
Questo potrebbe anche essere il problema che stai riscontrando: https://github.com/asterisk/node-ari-client/issues/ 35 –