Code Monkey home page Code Monkey logo

node-ari-client's Introduction

The Asterisk(R) Open Source PBX

        By Mark Spencer <[email protected]> and the Asterisk.org developer community.
        Copyright (C) 2001-2021 Sangoma Technologies Corporation and other copyright holders.

SECURITY

It is imperative that you read and fully understand the contents of the security information document before you attempt to configure and run an Asterisk server.

See Important Security Considerations for more information.

WHAT IS ASTERISK ?

Asterisk is an Open Source PBX and telephony toolkit. It is, in a sense, middleware between Internet and telephony channels on the bottom, and Internet and telephony applications at the top. However, Asterisk supports more telephony interfaces than just Internet telephony. Asterisk also has a vast amount of support for traditional PSTN telephony, as well.

For more information on the project itself, please visit the Asterisk home page and the official documentation. In addition you'll find lots of information compiled by the Asterisk community at voip-info.org.

There is a book on Asterisk published by O'Reilly under the Creative Commons License. It is available in book stores as well as in a downloadable version on the asteriskdocs.org web site.

SUPPORTED OPERATING SYSTEMS

Linux

The Asterisk Open Source PBX is developed and tested primarily on the GNU/Linux operating system, and is supported on every major GNU/Linux distribution.

Others

Asterisk has also been 'ported' and reportedly runs properly on other operating systems as well, including Sun Solaris, Apple's Mac OS X, Cygwin, and the BSD variants.

GETTING STARTED

First, be sure you've got supported hardware (but note that you don't need ANY special hardware, not even a sound card) to install and run Asterisk.

Supported telephony hardware includes:

  • All Analog and Digital Interface cards from Sangoma
  • QuickNet Internet PhoneJack and LineJack
  • any full duplex sound card supported by ALSA, OSS, or PortAudio
  • any ISDN card supported by mISDN on Linux
  • The Xorcom Astribank channel bank
  • VoiceTronix OpenLine products

UPGRADING FROM AN EARLIER VERSION

If you are updating from a previous version of Asterisk, make sure you read the UPGRADE.txt file in the source directory. There are some files and configuration options that you will have to change, even though we made every effort possible to maintain backwards compatibility.

In order to discover new features to use, please check the configuration examples in the configs directory of the source code distribution. For a list of new features in this version of Asterisk, see the CHANGES file.

NEW INSTALLATIONS

Ensure that your system contains a compatible compiler and development libraries. Asterisk requires either the GNU Compiler Collection (GCC) version 4.1 or higher, or a compiler that supports the C99 specification and some of the gcc language extensions. In addition, your system needs to have the C library headers available, and the headers and libraries for ncurses.

There are many modules that have additional dependencies. To see what libraries are being looked for, see ./configure --help, or run make menuselect to view the dependencies for specific modules.

On many distributions, these dependencies are installed by packages with names like 'glibc-devel', 'ncurses-devel', 'openssl-devel' and 'zlib-devel' or similar.

So, let's proceed:

  1. Read this file.

There are more documents than this one in the doc directory. You may also want to check the configuration files that contain examples and reference guides in the configs directory.

  1. Run ./configure

Execute the configure script to guess values for system-dependent variables used during compilation. If the script indicates that some required components are missing, you can run ./contrib/scripts/install_prereq install to install the necessary components. Note that this will install all dependencies for every functionality of Asterisk. After running the script, you will need to rerun ./configure.

  1. Run make menuselect [optional]

This is needed if you want to select the modules that will be compiled and to check dependencies for various optional modules.

  1. Run make

Assuming the build completes successfully:

  1. Run make install

If this is your first time working with Asterisk, you may wish to install the sample PBX, with demonstration extensions, etc. If so, run:

  1. Run make samples

Doing so will overwrite any existing configuration files you have installed.

  1. Finally, you can launch Asterisk in the foreground mode (not a daemon) with:
        # asterisk -vvvc

You'll see a bunch of verbose messages fly by your screen as Asterisk initializes (that's the "very very verbose" mode). When it's ready, if you specified the "c" then you'll get a command line console, that looks like this:

        *CLI>

You can type "core show help" at any time to get help with the system. For help with a specific command, type "core show help ". To start the PBX using your sound card, you can type "console dial" to dial the PBX. Then you can use "console answer", "console hangup", and "console dial" to simulate the actions of a telephone. Remember that if you don't have a full duplex sound card (and Asterisk will tell you somewhere in its verbose messages if you do/don't) then it won't work right (not yet).

"man asterisk" at the Unix/Linux command prompt will give you detailed information on how to start and stop Asterisk, as well as all the command line options for starting Asterisk.

Feel free to look over the configuration files in /etc/asterisk, where you will find a lot of information about what you can do with Asterisk.

ABOUT CONFIGURATION FILES

All Asterisk configuration files share a common format. Comments are delimited by ';' (since '#' of course, being a DTMF digit, may occur in many places). A configuration file is divided into sections whose names appear in []'s. Each section typically contains two types of statements, those of the form 'variable = value', and those of the form 'object => parameters'. Internally the use of '=' and '=>' is exactly the same, so they're used only to help make the configuration file easier to understand, and do not affect how it is actually parsed.

Entries of the form 'variable=value' set the value of some parameter in asterisk. For example, in chan_dahdi.conf, one might specify:

	switchtype=national

In order to indicate to Asterisk that the switch they are connecting to is of the type "national". In general, the parameter will apply to instantiations which occur below its specification. For example, if the configuration file read:

	switchtype = national
	channel => 1-4
	channel => 10-12
	switchtype = dms100
	channel => 25-47

The "national" switchtype would be applied to channels one through four and channels 10 through 12, whereas the "dms100" switchtype would apply to channels 25 through 47.

The "object => parameters" instantiates an object with the given parameters. For example, the line "channel => 25-47" creates objects for the channels 25 through 47 of the card, obtaining the settings from the variables specified above.

SPECIAL NOTE ON TIME

Those using SIP phones should be aware that Asterisk is sensitive to large jumps in time. Manually changing the system time using date(1) (or other similar commands) may cause SIP registrations and other internal processes to fail. If your system cannot keep accurate time by itself use NTP to keep the system clock synchronized to "real time". NTP is designed to keep the system clock synchronized by speeding up or slowing down the system clock until it is synchronized to "real time" rather than by jumping the time and causing discontinuities. Most Linux distributions include precompiled versions of NTP. Beware of some time synchronization methods that get the correct real time periodically and then manually set the system clock.

Apparent time changes due to daylight savings time are just that, apparent. The use of daylight savings time in a Linux system is purely a user interface issue and does not affect the operation of the Linux kernel or Asterisk. The system clock on Linux kernels operates on UTC. UTC does not use daylight savings time.

Also note that this issue is separate from the clocking of TDM channels, and is known to at least affect SIP registrations.

FILE DESCRIPTORS

Depending on the size of your system and your configuration, Asterisk can consume a large number of file descriptors. In UNIX, file descriptors are used for more than just files on disk. File descriptors are also used for handling network communication (e.g. SIP, IAX2, or H.323 calls) and hardware access (e.g. analog and digital trunk hardware). Asterisk accesses many on-disk files for everything from configuration information to voicemail storage.

Most systems limit the number of file descriptors that Asterisk can have open at one time. This can limit the number of simultaneous calls that your system can handle. For example, if the limit is set at 1024 (a common default value) Asterisk can handle approximately 150 SIP calls simultaneously. To change the number of file descriptors follow the instructions for your system below:

PAM-BASED LINUX SYSTEM

If your system uses PAM (Pluggable Authentication Modules) edit /etc/security/limits.conf. Add these lines to the bottom of the file:

root            soft    nofile          4096
root            hard    nofile          8196
asterisk        soft    nofile          4096
asterisk        hard    nofile          8196

(adjust the numbers to taste). You may need to reboot the system for these changes to take effect.

GENERIC UNIX SYSTEM

If there are no instructions specifically adapted to your system above you can try adding the command ulimit -n 8192 to the script that starts Asterisk.

MORE INFORMATION

See the doc directory for more documentation on various features. Again, please read all the configuration samples that include documentation on the configuration options.

Finally, you may wish to visit the support site and join the mailing list if you're interested in getting more information.

Welcome to the growing worldwide community of Asterisk users!

        Mark Spencer, and the Asterisk.org development community

Asterisk is a trademark of Sangoma Technologies Corporation

node-ari-client's People

Contributors

chadxz avatar coreyfarrell avatar danjenkins avatar dependabot[bot] avatar doug-lethin-simplisafe avatar erinishimoticha avatar glyphcezillesantillan avatar gtjoseph avatar leedm777 avatar marcbachmann avatar matt-jordan avatar mpotra avatar ruffrey avatar samuelg avatar yeya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-ari-client's Issues

channels.create hangs when there is no connection

If the connection's been lost and I'm trying to call channels.create on the client, the returned promise is never resolved or rejected, nor is there any error thrown. I don't know if this is related to #35 but #12 certainly doesn't fix it. The same happens with channel.dial. I think other channel functions may behave the same.

How to get the status of a failed playback

When I try to play a non-existing media by doing something like this

        channel.play({media: 'sound:nonexisting'}, playback).then(function() {
            console.log('Everything is fine');
        }).catch((err) => {
            console.log('Error>', err);
        });

I never get an error even though in asterisk's logs I can find

WARNING[10620] res_stasis_playback.c: 1481280112.80: Playback failed for sound:nonexisting

I don't know if this is a node-ari-client issue or rather an ari one. I haven't been able to create an issue in https://github.com/asterisk/asterisk repo.

Options for backoff in connect()

Hi,

Is it possible to add a parameter "option" in ari connect function to configure maxRetries, maxDelay and delay for backoff ?

Can you allow move the Client out to another file?

This would make stubbing a couple of methods (namely connecting to the ARI) far easier in my tests, right now, as the Client isn't exported anywhere before it's instantiated I can't do that and I'll have to just mock up a server or something which I don't really want to do...

More than happy to do this myself if you agree!

Problem with ari-client : sendMessage

I use your API, ari-client, but I have a problem with the function "sendMessageToEndpoint". I use it like this :

ari.endpoints.sendMessageToEndpoint({
        from: 'AstSae',
        tech: 'SIP', resource: '91',
        body: 'ESSAI',
        variables: []},
        function (err) {
            if (err) {
                throw err;
            }
        });

But the ARI request is :

PUT /ari/endpoints/SIP/91/sendMessage?from=AstSae HTTP/1.1
user-agent: Shred
Content-Type: application/json
Accept: application/json
Authorization: Basic YXJpdGVzdDp0ZXN0bWU=
Content-Length: 16
Host: 192.168.50.90:8088
Connection: keep-alive

{"variables":[]}

I can not see the body message.
And the resulting SIP message sending to SIP/91 is :

MESSAGE sip:[email protected];line=b6e881de237c150 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.90:5060;branch=z9hG4bK5c0bc190
Max-Forwards: 70
From: "AstSae" <sip:[email protected]>;tag=as43280f06
To: <sip:[email protected];line=b6e881de237c150>
Contact: <sip:[email protected]:5060>
Call-ID: 6399e2172b93f6092e82f6a229f7139c@[fe80::a65d:36ff:fecf:db94]:5060
CSeq: 102 MESSAGE
User-Agent: Asterisk PBX 13.5.0
Content-Type: text/plain;charset=UTF-8
Content-Length: 0

There is no Body Message.

Could you help me to understand ?

Best regards,

Documentation: Passing playbacks as parameters for .play()

When you have a channel, you can call this line of code and pass a playback without any issues:

channel.play({media: sound}, playback, function (err, playback) {});

This gives the same playback id for the start and finish events.
When you only have the channel id, it works differently:

ari.channels.play({media: sound, channelId: chanId, playbackId: playId}, function (err, playback) {});

The playback id needs to be specified in the options, rather than passing a playback object as a parameter. Slight discrepancy between the two ".play()" calls.

how to get call originate event

how to get current status of a call originate in ARI,means staus of call-originated is at -> local end is ringing OR remote end is ringing OR remote end is busy etc.

Swagger Client Out of Date

[ 'This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info' ]

Getting this output any time the client is instantiated.

ws build failure on win10 x64

there're a lot of errors blocking the build of this module, e.g.

\node_modules\ari-client\node_modules\ws\node_modules\nan\nan.h(213):
error C2039: 'ThrowException': is not a member of 'v8'
error C2039: 'New': is not a member of 'v8::String'
error C3861: 'New': identifier not found

upgrade ws to the latest version 1.1.0 will solve this on my end.
possible to update the dependencies?

Swagger API deprecated message

I've searched for this all I can. I can't seem to locate anything other than how it may be fixed. When I load a program with ari-client I get the message:

[ 'This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info' ]

It does appear that ari-client is using ver 1.2 which is the latest. And it's setting "swaggerVersion": "1.2" which also appears to be the correct setting.

Should I just ignore this?

Thank you!

replace jsdoc with a non-abandoned project

It seems that jsdoc has been abandoned... most people that want to see patches land in the project have decided to just fork it and make the changes themselves. I know that @ruffrey also has a fork of the project called jsdoxy.

In any case, we should move away from this package if we want to make sure we get updates to its dependencies and any bugs fixed ever.

getStoredFile() fails

Description:

Asterisk 14 introduces the ability to fetch a recording file, which is transmitted in binary.

The getStoredFile() method fails with the following error:

RIFFd`
^

SyntaxError: Unexpected token R in JSON at position 0
at Object.parse (native)
at SwaggerRequest.processResponse (/myapp/node_modules/ari-client/lib/client.js:261:31)
at Object.response (/myapp/node_modules/swagger-client/lib/swagger.js:1086:24)
at EventEmitter.response (/myapp/node_modules/swagger-client/lib/swagger.js:1308:19)
at emitOne (events.js:96:13)
at EventEmitter.emit (events.js:188:7)
at emit (/myapp/node_modules/shred/lib/shred/request.js:456:21)
at /myapp/node_modules/shred/lib/shred/request.js:476:9
at setBodyAndFinish (/myapp/node_modules/shred/lib/shred/response.js:103:7)
at IncomingMessage. (/myapp/node_modules/shred/lib/shred/response.js:120:7)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

I've tracked this error to JSON.parse(result) attempting to parse a non-JSON binary string, instead of handling the Buffer object.

Resource specific events inconsistent with Client events

Client events use a built in EventEmitter. Resource specific events however use a wrapper around an EventEmitter. Some of the implementation is inconsistent with the way an EventEmitter should work.

1 - attaching more than one callback via resource.on('event', callback) only attaches the first callback
2 - removeListener acts like removeAllListeners but does not actually remove the underlying EventEmitter attached callback
3 - removeAllListeners is not implemented

No playback after hangup

Hi there, just came across this module and find it amazing!
So I tried setting up the example application (playback.js) and upon hangup I get the following message in the asterisk CLI

WARNING[15517][C-00000001]: res_stasis_playback.c:248 playback_final_update: 1459630813.2: Playback failed for sound:demo-congrats

When I call back that same extension that should play the example once again, I get no playback just a blank call. Upon restarting the node app I get the sound to play again.

Is there anything I may be doing wrong is does it have something to do with the playback.js code?

Swagger needs to be updated

Using this project, connection to a newly installed asterisk 13.6.0 gives the following error:

[ 'This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info' ]

The correct way to make a call

Surprisingly, I haven't found an example of this. Here is how I am doing it

client.start('hello-world');

client.channels.create({app: 'hello-world', endpoint: 'Local/79991111111@sip-dialout'}).then(localChannel => {
    console.log('STAGE 1: ', localChannel.state);

    localChannel.dial().then(() => {
        console.log('STAGE 2: ', localChannel.state);
    }).error(function(err) {
        console.log('ERROR 2:', err);
    });
}).error(function(err) {
    console.log('ERROR 1: ', arguments);
});

Which usually works, i.e. I get a phone call on +79991111111 but sometimes instead I get the following error

STAGE 1: Down
ERROR 2: Error: {"message":"Channel not found"}
at SwaggerRequest.swaggerError [as errorCallback] (/usr/lib/node_modules/ari-client/lib/resources.js:944:19)
at Object.error (/usr/lib/node_modules/ari-client/node_modules/swagger-client/lib/swagger.js:1077:24)
at EventEmitter.error (/usr/lib/node_modules/ari-client/node_modules/swagger-client/lib/swagger.js:1296:19)
at emitOne (events.js:96:13)
at EventEmitter.emit (events.js:188:7)
at emit (/usr/lib/node_modules/ari-client/node_modules/shred/lib/shred/request.js:454:21)
at /usr/lib/node_modules/ari-client/node_modules/shred/lib/shred/request.js:473:9
at setBodyAndFinish (/usr/lib/node_modules/ari-client/node_modules/shred/lib/shred/response.js:103:7)
at IncomingMessage. (/usr/lib/node_modules/ari-client/node_modules/shred/lib/shred/response.js:120:7)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

This is the context from extensions.conf

[sip-dialout]
exten => _X.,1,Dial(SIP/zebra/+${EXTEN})
exten => _X.,n,Hangup()

What am doing wrong?

'ChannelDtmfReceived' event not emitting

hello ,
when i put more than one channel in a bridge, in this case event 'ChannelDtmfReceived' not emitting for all those channel , who are in created bridge.

Note :- event 'ChannelDtmfReceived' is emitting ,when single channel in a bridge.

Error when working with non existing channels

For example when I got channelHangupRequest I want to hangup other party of a call. But the other party already could be hanged up due to transfer (e.g. without hangup request). So when i try to manipulate this channel by id I get uncatchable error:

/var/daemon/node_modules/ari-client/lib/client.js:244
userCallback(err);
^
TypeError: object is not a function
at swaggerError as errorCallback
at Object.obj.on.error (/var/daemon/node_modules/ari-client/node_modules/swagger-client/lib/swagger.js:1077:24)
at EventEmitter.res.error (/var/daemon/node_modules/ari-client/node_modules/swagger-client/lib/swagger.js:1296:19)
at EventEmitter.emit (events.js:109:17)
at emit (/var/daemon/node_modules/ari-client/node_modules/swagger-client/node_modules/shred/lib/shred/request.js:454:21)
at /var/daemon/node_modules/ari-client/node_modules/swagger-client/node_modules/shred/lib/shred/request.js:473:9
at setBodyAndFinish (/var/daemon/node_modules/ari-client/node_modules/swagger-client/node_modules/shred/lib/shred/response.js:103:7)
at IncomingMessage. (/var/daemon/node_modules/ari-client/node_modules/swagger-client/node_modules/shred/lib/shred/response.js:120:7)
at IncomingMessage.emit (events.js:131:20)
at _stream_readable.js:910:16

Yea, I know I should take care of that and prevent the use of non-existing channels but from the other side my worker can crash and stop if non existing channeld is used in ari.channels.hangup({}). Let me know if you consider this is an issue or not. Thanks in advance!

ari-client.connect authentication error should be catchable

Here is a very simple use case

try {
    ari.connect(config.url, config.user, config.pass, connErr => {
        if (connErr) {
            logger.log('error', 'caught from callback', connErr);

            return;
        }

        logger.log('info', 'connected');
    }).catch(e => {
        logger.log('error', 'caught from promise', e);
    });
} catch (e) {
    logger.log('error', 'caught from try-catch', e);
}

If the credentials are invalid I get this error message and the program exits.

/home/artyom/WebstormProjects/pbsw-dialer/node_modules/swagger-client/lib/swagger.js:270
throw message;
^
401 : undefined http://localhost:8088/ari/api-docs/resources.json

I never actually catch the error which means I can't perform a resource cleanup or produce a custom error message or wrap the error or anything like that. I believe all connection errors should be catchable.

Event handler leak

There is a kind of "memory leak" in the list of event handlers (the _instanceListeners attribute of the client object): if event handlers are registered on a channel, they are kept in memory event when the channel no longer exists.

Of course, this can be avoided by explicitly calling the method removeAllListeners with the previously used events just before the channel disappears, but this behaviour is really unexpected.

If there is no general way to solve this issue, I think it should at least be documented.

Allow events of a child Local channel to fire the listeners registered on its parent

Hello,

I am having a problem with the handling of events triggered by a Local channel, which do not fire the listeners registered on its parent. The problem is a bit complex to explain, I will take an example:

  • First, I create a channel and register a listener on it:
var chan = ari.Channel();
chan.on('Dial', function(event) {
    console.log('Dial received!');
});
  • Then, I do an originate on this channel, targeting a Local endpoint:
chan.originate({
    endpoint: 'Local/exten@context',
    app: 'myApp',
    appArgs: 'foo,bar'
});

The dialplan located at exten@context is doing a Dial to a SIP peer, so I would expect to see Dial received in the console, but it is not happening. However, I can see Dial events coming from the websocket.

After looking more closely at the events and digging through the code, I figured out that this has something to do with the fact that when we originate a Local endpoint, Asterisk actually creates two Local channels connected by a virtual endpoint. And my listener is registered on the first Local channel, but it is the second Local channel which triggers the Dial events.

To be more precise, I register the events on a channel named 123456.789 (for example), but the Dial events are bound to the "child" channel 123456.789;2.

As there is no way to retrieve a reference to the child channel and thus register event handlers on it, I suggest that events bound to the child channel should trigger the listeners registered on the parent channel.

What do you think of that ? I did this modification on my own, I may submit it as a pull request if you will.

Client.prototype.start undefined apps silently dies

If for some reason, a developer will try to start a Stasis application that has an undefined name (yes, it's stupid, but may happen), Client will not return any type of error or exception.

The issue should be handled within Client.prototype.start (I think):

Client.prototype.start = function (apps, subscribeAll, callback) {
  var self = this;
  // are we currently processing a WebSocket error?
  var processingError = false;

  // Perform argument renaming for backwards compatibility
  if (typeof subscribeAll === 'function') {
    callback = subscribeAll;
    subscribeAll = null;
  }

This may also provide some easy resolution for issue #35

client.connect() does not throw exception on no connection

When using client.connect() to connect to a Asterisk server (v 13.6.0), the client.connec() command does not throw an exception, emit any event nor do anything when it cannot connect to the server. This makes it impossible to detect if the client is actually connected or not

Initial connection failure : update swagger-client ?

Currently, if Asterisk is not started when ari-client tries to open a connection, the error callback is not fired as we would expect to.

It seems to be a bug in swagger-client, which is apparently fixed in the latest version (2.1.26 this day). I cannot figure out precisely which version fixed this, but my own tests suggest it is actually working in the current one.

So, is it possible to update the swagger-client version to 2.1.26 ?

adding multiple channels to a bridge

How to add multiple channels by sending only one request.

"channel (string) - Ids of channels to add to bridge" -> Cannot add multiple channels using a comma separated string.

Cryptic error when ARI user password has special characters

When calling ari.start(), I encountered a mysterious error that left the following trace:

Unhandled rejection Error: undefined
    at Object.ensureErrorObject (/home/<user>/src/<ari_app>/node_modules/bluebird/js/main/util.js:261:20)
    at Promise._rejectCallback (/home/<user>/src/<ari_app>/node_modules/bluebird/js/main/promise.js:472:22)
    at /home/<user>/src/<ari_app>/node_modules/bluebird/js/main/promise.js:489:17
    at /home/<user>/src/<ari_app>/node_modules/ari-client/lib/client.js:327:11
    at /home/<user>/src/<ari_app>/node_modules/underscore/underscore.js:890:21
    at reconnect (/home/<user>/src/<ari_app>/node_modules/ari-client/lib/client.js:526:9)
    at WebSocket.processError (/home/<user>/src/<ari_app>/node_modules/ari-client/lib/client.js:509:7)
    at emitOne (events.js:77:13)
    at WebSocket.emit (events.js:169:7)
    at ClientRequest.response (/home/<user>/src/<ari_app>/node_modules/ws/lib/WebSocket.js:721:12)
    at ClientRequest.g (events.js:260:16)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at HTTPParser.parserOnIncomingClient (_http_client.js:433:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)
    at Socket.socketOnData (_http_client.js:322:20)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:537:20)

Suspiciously, it occurred about a minute after connecting. Looking around, it turned out that my ARI user had some special characters (+) that weren't being escaped. When creating the websocket url, it added my user as is:

var wsUrl = util.format(
    '%s://%s/ari/events?app=%s&api_key=%s:%s',
    (self._connection.protocol === 'https:' ? 'wss' : 'ws'),
    self._connection.host,
    applications,
    self._connection.user,     // <-- may be unsafe
    self._connection.pass
);

It resulted in 401s that didn't bubble up well, and finally culminated in the above error.

Is this a bug? Or should I be url-encoding my own usernames/passwords...or should I simply avoid special characters altogether?

unmute

I was attempting to use the mute and unmute channel options. The mute option worked just fine but the unmute didn't. If I used the direct Swagger UI delete mute call it was able to unmute the channel just fine.

Have you had any reports of this? I found another way around the issue. I was setting the role of a bridge to mixing when I should've been setting it to holding. But, I'm sure I'll need mute and unmute in the future.

Thank you!
Phil Mickelson

ari could not restart automatically

we use ari.start('hello-world') to active/create a stasis app in asterisk, a websocket connection is established. But if network error, the websocket will be disconnected. Then calls can't be made through ari stasis. So is there an event to check the websocket connection? or will ari stasis app be restarted automatically?

client.originate() doesn't set exten value on originated channel

I'm using a single stasis application to demo several ARI functionalities, and I'm using channel.dialplan.exten as a "switch" to tell between these sub-apps.

When I use a SIP phone and dial in the extension, exten is set accordingly. However, when calling out from ARI using client.originate({ extension: '1234', ... }), exten always contains an empty string (regardless of the channel source: the StasisStart event, originate callback, etc). Is this intentional? Why does it do that?

Thanks!

Documentation difficult to read

The library documentation on the README is difficult to parse visually. Would be great if there were some sort of table of contents, and if the different header levels were more visually distinct, perhaps using color, emoji, or anything to help.

Would also be good to document the api of the Channel object, and any other objects that we create that are not part of the swagger api

redirect doesnt work

whats supposed to happen if I redirect the channel?

I'm using

incoming.redirect({endpoint: 'SIP/sip-trunk/123456789'})
                .then(function () {
                        console.log('worked');
                })
                .catch(function (err) { console.log(err);});

and its only showing 'worked' in the console without actually doing something on the call.
Am I getting something wrong here?

Thanks & Cheers
Qiong

Error determining real directory for rest-api

I am not sure if it belongs here but it felt natural for me to put it here. I am running asterisk 13 on ubuntu 16. I enabled ari but when I try to use ari-client it says Error determining real directory for rest-api if I go to the web browser and try ari it says the same. it lets me in with user and password but then it wont serve the api.

ari.channels.create() and ari.channels.dial() function not working

Hello ,
I am talking about issue #77.
In this issue i am using ari.channels.create() then ari.channels.dial() but it gives type error:

/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/async.js:43
fn = function () { throw arg; };
^

TypeError: client.channels.create is not a function
at clientLoaded (/usr/local/lib/node_modules/sarvIVR/IVR/mahi_callTransfer.js:163:25)
at tryCatcher (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/util.js:26:23)
at Promise.successAdapter (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/nodeify.js:23:30)
at Promise._settlePromiseAt (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/promise.js:582:21)
at Promise._settlePromises (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/promise.js:700:14)
at Async._drainQueue (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/ari-client/node_modules/bluebird/js/main/async.js:15:14)
at processImmediate [as _immediateCallback] (timers.js:383:17)

ws dependency not compiling in node 0.12.7

I got the following error when trying to npm install ari-client:

> [email protected] install /usr/src/app/node_modules/ari-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

make: Entering directory '/usr/src/app/node_modules/ari-client/node_modules/ws/build'
  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
bufferutil.target.mk:90: recipe for target 'Release/obj.target/bufferutil/src/bufferutil.o' failed
make: Leaving directory '/usr/src/app/node_modules/ari-client/node_modules/ws/build'

It appears that the older version of ws is not compatible with node 0.12.7 seeing that I was able to build ws 0.7.2 successfully on node 0.12.7.

Listen to multiple instanses

Hi. In my small project become necessary listen multiple ARI instances same time, and interact with it. And now, i really don't have any idea how to realize this feature. Can you get me something like advice, or something like that? I don`t asking for working code, just for advice.

Thanks.

Support sending via the ARI Proxy Messaging Protocol

I'd love to be able to use this library with the ARI Proxy messaging protocol and send/recieve via a message bus such as RabbitMQ rather than via Websocket/HTTP.

The ARI is great except that it really limits us to a 1:1 relationship.

Both the .NET and Go ARI Clients don't rely on getting a resource list from the API on startup which makes utilising the Proxy easier. The other issue is that everything utilises the swagger-client to generate request bodies etc from what I can see - which again limits the clients use as its tied to swagger.

I'd love to have a chat about the best way to implement this so that I don't come to put a PR in and have it rejected. @samuelg @erinspice @matt-jordan

I'd prefer to just have the one ARI client on npm but I'm starting to wonder if I should just fork the project, remove all the swagger cleverness and go down the route of what .NET and Go did - generate all the functions etc from the resources file whenever Asterisk changes - don't do it on every startup (which must add time to all app startup times) and not using swagger to do the HTTP/Websocket calls etc.

Let me know your thoughts!

connecting over wss doesn't work

The library expects to connect to Asterisk's Websocket over WS, but in my current scenario, Asterisk has TLS and port 80 isnt exposed to the public internet. And so I'm connecting via WSS - the lib hardcodes WS - we should make this configurable

'channelStateChange' not emmiting properly.

'channelStateChange' not emmiting on channel-state-change for event 'Rsrvd' and such more events. Currently i am using Asterisk 14 and using node-ari-client 1.1.0,
and also list events name for channelStateChange.

Thanks.

Swagger.js does not respect body parameter type

For ARI operations that support parameters in a POST body (channel origination channel variables for example), Swagger.js does not respect the parameter type.

Passing

{variables: {}}

to an ARI operation call does not send the variables in the POST body. The parameter must be passed as

{body: '{}'}

where the json is sent as a string.

ari-client should abstract this issue out and convert parameters with a body parameter type to use the Swagger.js body parameter option and convert JavaScript objects to a json string.

An ari-client unit test should also be written to cover this issue.

Getting a swagger caution

On connecting to Asterisk I'm getting this error message?

[ 'This API is using a deprecated version of Swagger!  Please see http://github.com/wordnik/swagger-core/wiki for more info' ]

ari only response to the first call

node-ari-client: 0.1.5
nodejs: v0.10.32
asterisk: 13.0.0-beta3

the first call works fine, if I hangup and dial again, nothing happen, call hit Stasis but there're no log from nodejs, if I break nodejs and run again, it will work, but only for 1st call.

Update README

Update the generated README using the latest version of Asterisk.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.