Andrew
Andrew

Reputation: 63

Cannot create Asterisk Stasis App using ari4java library

I am using ari4java library and I have a problem with registering a stasis application. If I use the command line to connect to Asterisk and listen for events for a specific application name it works. It creates the application and everything is OK. The problem appears when I do it by using the ari4java library in Java. Actually, I'm trying the example from the library's github repository (i.e. - ConnectAndDial.java)[1]. I understand that the ARI.build(...) call:

ari = ARI.build(
ASTERISK_ADDRESS,
"app_test",
ASTERISK_USER,
ASTERISK_PASS,
AriVersion.ARI_3_0_0
);

must create an application named "app_test". The reality is that it does not.

for (Application app : ari.applications().list()) {
System.out.print(app.getName() + " ");
}

The code above, executed after ARI.build(...) prints nothing. That means there is no application registered in Asterisk. Running "ari show apps" in Asterisk CLI also tells me that there is no app registered.

I can't understand, where is the problem? Can somebody, please, help me with this?

Thanks in advance.

P.S.: I am using Asterisk 15.4.0

[1] https://github.com/l3nz/ari4java/blob/master/tests/ch/loway/oss/ari4java/sandbox/sample/ConnectAndDial.java

Upvotes: 1

Views: 1005

Answers (1)

angie
angie

Reputation: 38

First of all you need to create an instance of ARI using ARI.build, as you did. For example:

ARI ari = ARI.build(asteriskUrl, "stasisApp", "userid", "secret", AriVersion.ARI_3_0_0);

Besides that you need to define configuration files as follows:

  1. ari.conf - a configuration file that defines user and asterisk properties:
[general]
enabled = yes
pretty = yes

[userid]
type = user
read_only = no
password = secret
  1. extensions.conf - define a dialpan for the application you want to run:

[general]
enabled = yes
pretty = yes

[userid]
type = user
read_only = no
password = secret
  1. http.conf - HTTP server configuration:
[general]
enabled = yes
bindaddr = 0.0.0.0
bindport = 8088

In addition, after creating ARI instance you can open a websocket to listen to ARI events, using: ari.events().eventWebsocket("stasisApp", true, ariCallback);

Upvotes: 1

Related Questions