[Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Alessio Turini

Dear,
I've a problem with the class DefaultAsteriskServer and the 
connection with the Asterisk (V. 11.19.0), i'll try to explain below 
(and sorry for my english)


I develop a program that links inbound call with a couple of events, I 
use the class DefaultAsteriskServer and the listener 
addAsteriskServerListener(MyClass).
MyClass checks every call and makes different operation based on type of 
call.
The program is ok but after 10/20 hours goes to Hollywood, this means 
that the listener not link events.

The class DefaultAsteriskServer is declared in a static object that wrap it.
I would to ask, there is a timeout of connection between Asterisk and 
DefaultAsteriskServer , can i check the connection between the two actor?
I tried to check the state of ManagerConnection (get by 
getManagerConnection() on DefaultAsteriskServer ) but the result is 
always connected and not help me to restablished a connection.


Thanks in advance, Alessio


--
*Dott. Alessio Turini*
IT Dept - Credires
Via Don Luigi Sturzo 4, Pontedera, Pisa, Italy
+39 0587 467716 - +39 3457427943 - a.tur...@credires.it
Le informazioni contenute in questo messaggio di posta elettronica e/o 
nel/i file/s allegato/i, sono da considerarsi strettamente riservate. Il 
loro utilizzo è consentito esclusivamente al destinatario del messaggio, 
per le finalità indicate nel messaggio stesso. Qualora riceveste questo 
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di 
darcene notizia via e-mail all'indirizzo i...@credires.it o 
telefonicamente allo +390587467700 e procedere alla distruzione del 
messaggio stesso, cancellandolo dal Vostro sistema; costituisce 
comportamento contrario ai principi dettati dal Dlgs 196/2003 il 
trattenere il messaggio stesso, divulgarlo anche in parte, distribuirlo 
ad altri soggetti, copiarlo, od utilizzarlo per finalità, diverse.
This message and any attachments are solely for the intended recipient 
and may contain confidential or privileged information. Its use is 
allowed only to the intended recipient, for the purpose indicated in the 
message itself. If you are not the intended recipient, please notify us 
by email to i...@credires.it or by phone to +390587467700 and 
permanently delete this message and any attachments in your system. 
Keeping, disclosure also in part, distribution to other recipients, 
copying of the information included in this message and any attachments 
or using this information for different purposes is prohibited as per 
regulation Dlgs 196/2003.
--
___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users


Re: [Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Yves

Hi Alessio,

as my glassbowl is currently under repair, I cannot guess your source 
code so why not append it to your next eMail so that we can have a 
look at it?


regards,
yves

Am 12.11.2015 um 09:11 schrieb Alessio Turini:

Dear,
I've a problem with the class DefaultAsteriskServer and the 
connection with the Asterisk (V. 11.19.0), i'll try to explain below 
(and sorry for my english)


I develop a program that links inbound call with a couple of events, I 
use the class DefaultAsteriskServer and the listener 
addAsteriskServerListener(MyClass).
MyClass checks every call and makes different operation based on type 
of call.
The program is ok but after 10/20 hours goes to Hollywood, this means 
that the listener not link events.
The class DefaultAsteriskServer is declared in a static object that 
wrap it.
I would to ask, there is a timeout of connection between Asterisk and 
DefaultAsteriskServer , can i check the connection between the two actor?
I tried to check the state of ManagerConnection (get by 
getManagerConnection() on DefaultAsteriskServer ) but the result is 
always connected and not help me to restablished a connection.


Thanks in advance, Alessio


--
*Dott. Alessio Turini*
IT Dept - Credires
Via Don Luigi Sturzo 4, Pontedera, Pisa, Italy
+39 0587 467716 - +39 3457427943 - a.tur...@credires.it
Le informazioni contenute in questo messaggio di posta elettronica e/o 
nel/i file/s allegato/i, sono da considerarsi strettamente riservate. 
Il loro utilizzo è consentito esclusivamente al destinatario del 
messaggio, per le finalità indicate nel messaggio stesso. Qualora 
riceveste questo messaggio senza esserne il destinatario, Vi preghiamo 
cortesemente di darcene notizia via e-mail all'indirizzo 
i...@credires.it o telefonicamente allo +390587467700 e procedere alla 
distruzione del messaggio stesso, cancellandolo dal Vostro sistema; 
costituisce comportamento contrario ai principi dettati dal Dlgs 
196/2003 il trattenere il messaggio stesso, divulgarlo anche in parte, 
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità, 
diverse.
This message and any attachments are solely for the intended recipient 
and may contain confidential or privileged information. Its use is 
allowed only to the intended recipient, for the purpose indicated in 
the message itself. If you are not the intended recipient, please 
notify us by email to i...@credires.it or by phone to +390587467700 
and permanently delete this message and any attachments in your 
system. Keeping, disclosure also in part, distribution to other 
recipients, copying of the information included in this message and 
any attachments or using this information for different purposes is 
prohibited as per regulation Dlgs 196/2003.



--


___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users




---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus
--
___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users


[Asterisk-java-users] sample asterisk dial plan integration with AGI java project (Eclipse)

2015-11-12 Thread Abdul Basit
Hi all,

I am new to asterisk, i would be very appreciate if any one would like to share 
sample dial plan integration with AGI  based on Java Eclipse. thx


I manage to setup Asterisk Environment in my machine. thx





Regards,
AB
  --
___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users


Re: [Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Zoumana TRAORE
Hi Alessio,

You probably need to share a part of the code so we can help.
I assume you did not maintain some how you AMI Connection.

Here is how i did it using PingThread provided by the AJ library

@Autowired
private PingThread pingThread;

/**
 * 
 * Connect to Asterisk Server via Live API
 * 
 * @return
 */
public void connect(){
asteriskServer = new DefaultAsteriskServer(asteriskLiveHost,
asteriskUsername, asteriskPassword);
asteriskServer.initialize();
pingThread.addConnection(asteriskServer.getManagerConnection());
}


And you fire the PingThread for instance at your app boot-up
if(pingThread != null && !pingThread.isAlive()){
   pingThread.start();
}


Regards,

*---*

*Zoumana TRAORE*

2015-11-12 10:28 GMT+01:00 Yves :

> Hi Alessio,
>
> as my glassbowl is currently under repair, I cannot guess your source
> code so why not append it to your next eMail so that we can have a look
> at it?
>
> regards,
> yves
>
>
> Am 12.11.2015 um 09:11 schrieb Alessio Turini:
>
> Dear,
> I've a problem with the class DefaultAsteriskServer and the connection
> with the Asterisk (V. 11.19.0), i'll try to explain below (and sorry for my
> english)
>
> I develop a program that links inbound call with a couple of events, I use
> the class DefaultAsteriskServer and the listener
> addAsteriskServerListener(MyClass).
> MyClass checks every call and makes different operation based on type of
> call.
> The program is ok but after 10/20 hours goes to Hollywood, this means that
> the listener not link events.
> The class DefaultAsteriskServer is declared in a static object that wrap
> it.
> I would to ask, there is a timeout of connection between Asterisk and
> DefaultAsteriskServer , can i check the connection between the two actor?
> I tried to check the state of ManagerConnection (get by
> getManagerConnection() on DefaultAsteriskServer ) but the result is always
> connected and not help me to restablished a connection.
>
> Thanks in advance, Alessio
>
>
> --
> *Dott. Alessio Turini*
> IT Dept - Credires
> Via Don Luigi Sturzo 4, Pontedera, Pisa, Italy
> +39 0587 467716 - +39 3457427943 - a.tur...@credires.it
> Le informazioni contenute in questo messaggio di posta elettronica e/o
> nel/i file/s allegato/i, sono da considerarsi strettamente riservate. Il
> loro utilizzo è consentito esclusivamente al destinatario del messaggio,
> per le finalità indicate nel messaggio stesso. Qualora riceveste questo
> messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
> darcene notizia via e-mail all'indirizzo i...@credires.it o
> telefonicamente allo +390587467700 e procedere alla distruzione del
> messaggio stesso, cancellandolo dal Vostro sistema; costituisce
> comportamento contrario ai principi dettati dal Dlgs 196/2003 il trattenere
> il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri
> soggetti, copiarlo, od utilizzarlo per finalità, diverse.
> This message and any attachments are solely for the intended recipient and
> may contain confidential or privileged information. Its use is allowed only
> to the intended recipient, for the purpose indicated in the message itself.
> If you are not the intended recipient, please notify us by email to
> i...@credires.it or by phone to +390587467700 and permanently delete this
> message and any attachments in your system. Keeping, disclosure also in
> part, distribution to other recipients, copying of the information included
> in this message and any attachments or using this information for different
> purposes is prohibited as per regulation Dlgs 196/2003.
>
>
> --
>
>
>
> ___
> Asterisk-java-users mailing 
> listAsterisk-java-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
>
>
> --
> [image: Avast logo] 
>
> Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
> www.avast.com 
>
>
>
> --
>
> ___
> Asterisk-java-users mailing list
> Asterisk-java-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
--
___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users


[Asterisk-java-users] Remove my account

2015-11-12 Thread Oscar Alvarez
Hi,

Can you remove my acount from the mail list?

Thx

Regards,

-- 
Oscar Alvarez
--
___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users


Re: [Asterisk-java-users] Remove my account

2015-11-12 Thread Zoumana TRAORE
Hello,

I think that you have to unsubscribe by yourself at
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users

Regards


*---*

*Zoumana TRAORE*

2015-11-12 10:59 GMT+01:00 Oscar Alvarez :

> Hi,
>
> Can you remove my acount from the mail list?
>
> Thx
>
> Regards,
>
> --
> Oscar Alvarez
>
>
> --
>
> ___
> Asterisk-java-users mailing list
> Asterisk-java-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
--
___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users


[Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Alessio Turini

Ok, thanks for the answers.
The code in answer is similar as mine, I try to insert a portion of 
project below , the class EventoAsterisk after a couple of hours(15 h) 
doesn't grab the events,

There is a mode to check this type of connection?
In the method run, i try to check mc object but the result is always 
connected.

Thanks Ale


class ManagerAsterisk extends Thread {

private String host;
private String user;
private String psw;
private DefaultAsteriskServer serverA;
private ManagerConnection mc;
private EventoAsterisk eventi;

ManagerAsterisk(String host, String user, String psw) {
Log.info("DefaultAsteriskServer start ");
this.host= host;
this.user= user;
this.psw= psw;
serverA = new DefaultAsteriskServer(host, user, psw);
serverA.initialize();

mc = serverA.getManagerConnection();


}

ManagerConnection getManagerConnection() {
return serverA.getManagerConnection();
}

void addAsteriskServerListener(EventoAsterisk eventi) {
this.eventi = eventi;
serverA.addAsteriskServerListener(eventi);
}

void removeAsteriskServerListener(EventoAsterisk eventi) {
Log.info("ManagerAsterisk.removeAsteriskServerListener - eventi 
:" + eventi);

serverA.removeAsteriskServerListener(eventi);
}

@Override
public void run() {
try {
while (true) {
Log.info("ManagerAsterisk.run - state (pre sleep) :" + 
mc.getState().name() + " - " + mc.getState());

Thread.sleep(20 * 1000);
ManagerConnectionState stato = mc.getState();
Log.info("ManagerAsterisk.run - state :" + 
mc.getState().name() + " - " + mc.getState());


if (!stato.equals(ManagerConnectionState.INITIAL) && 
!stato.equals(ManagerConnectionState.CONNECTING) && 
!stato.equals(ManagerConnectionState.CONNECTED)) {

Log.info("ManagerAsterisk.run - reacreate :" + stato);
serverA = new DefaultAsteriskServer(host, user, psw);
mc = serverA.getManagerConnection();
mc.addEventListener(new ConnessioneAsterisk());
serverA.addAsteriskServerListener(eventi);
stato = mc.getState();
Log.info("ManagerAsterisk.run - reacreated :" + stato);
}
}
} catch (InterruptedException ex) {
Log.error("ManagerAsterisk.run" + ex, ex);
}

}
}


Il 12/11/2015 10.50, Zoumana TRAORE ha scritto:

Hi Alessio,

You probably need to share a part of the code so we can help.
I assume you did not maintain some how you AMI Connection.

Here is how i did it using PingThread provided by the AJ library

@Autowired
private PingThread pingThread;

/**
 * 
 * Connect to Asterisk Server via Live API
 * 
 * @return
 */
public void connect(){
asteriskServer = new DefaultAsteriskServer(asteriskLiveHost, 
asteriskUsername, asteriskPassword);

asteriskServer.initialize();
pingThread.addConnection(asteriskServer.getManagerConnection());
}


And you fire the PingThread for instance at your app boot-up
if(pingThread != null && !pingThread.isAlive()){
   pingThread.start();
}


Regards,
*---
*

*Zoumana TRAORE*


2015-11-12 10:28 GMT+01:00 Yves mailto:yves...@gmx.de>>:

Hi Alessio,

as my glassbowl is currently under repair, I cannot guess your
source code so why not append it to your next eMail so that we
can have a look at it?

regards,
yves


Am 12.11.2015 um 09:11 schrieb Alessio Turini:

Dear,
I've a problem with the class DefaultAsteriskServer and the
connection with the Asterisk (V. 11.19.0), i'll try to explain
below (and sorry for my english)

I develop a program that links inbound call with a couple of
events, I use the class DefaultAsteriskServer and the listener
addAsteriskServerListener(MyClass).
MyClass checks every call and makes different operation based on
type of call.
The program is ok but after 10/20 hours goes to Hollywood, this
means that the listener not link events.
The class DefaultAsteriskServer is declared in a static object
that wrap it.
I would to ask, there is a timeout of connection between Asterisk
and DefaultAsteriskServer , can i check the connection between
the two actor?
I tried to check the state of ManagerConnection (get by
getManagerConnection() on DefaultAsteriskServer ) but the result
is always connected and not help me to restablished a connection.

Thanks in advance, Alessio


-- 
*Dott. Alessio Turini*

IT Dept - Credires
Via Don Luigi Sturzo 4, Pontedera, Pisa, Italy
+39 0587 467716  - +39 3457427943
 - a.tur...@credires.it

Le informazioni contenute in questo messaggio di posta
elettr

Re: [Asterisk-java-users] sample asterisk dial plan integration with AGI java project (Eclipse)

2015-11-12 Thread Yves

Hi,

the internet is full of examples... even the docs show it...:

https://maven.reucon.com/projects/public/asterisk-java/1.0.0/tutorial.html

http://www.jcgonzalez.com/asterisk-handle-calls-with-java-example

A google search on "asterisk-java agi example" results in tons of info.

regards,
yves


Am 12.11.2015 um 10:41 schrieb Abdul Basit:

Hi all,

I am new to asterisk, i would be very appreciate if any one would like
to share sample dial plan integration with AGI  based on Java Eclipse. thx


I manage to setup Asterisk Environment in my machine. thx





Regards,
AB


--


___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users




---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus
--
___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users


Re: [Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Yves

my thoughts after taking a quick look...:

I don´t see something essentially wrong... the listener only works, as 
long the object is "alive"... using it in a thread is ok, but i don´t 
see the code that initializes and finally "runs" the thread..
maybe you have deadslocks, or any other multithread related problems... 
or just a network-problem... (are asterisk and your programm running on 
different machines?)
getting the managerconnection the way you do it should work, but it may 
be better to go the recommended way (don´t know your environment) and 
use the managerfactory.

are you using at least the asterisk-java 1.0 api?
using a serverlistener does not fire much info... a managereventlistener 
would give you much more information...

maybe the thread-sleeptime of 20secs is too long...
are you sure, that your asterisk is fine all the time? maybe there are 
interference with reloads, crashes and so on? what do asterisk-logs say 
(increase verbosity or use debug log) when connections failes?
normally the managerconnection reestablishes the socketconnection, but 
this is not very stable... this only seems to work if the connection 
breaks after issuing a command... so relying on the result of getState
is quite useless... you should fire an action to reliably check the 
availability... this should of course be a command that does not consume 
much resources.. e.g. core show version etc.


yves




Am 12.11.2015 um 11:15 schrieb Alessio Turini:

Ok, thanks for the answers.
The code in answer is similar as mine, I try to insert a portion of 
project below , the class EventoAsterisk after a couple of hours(15 h) 
doesn't grab the events,

There is a mode to check this type of connection?
In the method run, i try to check mc object but the result is always 
connected.

Thanks Ale


class ManagerAsterisk extends Thread {

private String host;
private String user;
private String psw;
private DefaultAsteriskServer serverA;
private ManagerConnection mc;
private EventoAsterisk eventi;

ManagerAsterisk(String host, String user, String psw) {
Log.info("DefaultAsteriskServer start ");
this.host= host;
this.user= user;
this.psw= psw;
serverA = new DefaultAsteriskServer(host, user, psw);
serverA.initialize();

mc = serverA.getManagerConnection();


}

ManagerConnection getManagerConnection() {
return serverA.getManagerConnection();
}

void addAsteriskServerListener(EventoAsterisk eventi) {
this.eventi = eventi;
serverA.addAsteriskServerListener(eventi);
}

void removeAsteriskServerListener(EventoAsterisk eventi) {
Log.info("ManagerAsterisk.removeAsteriskServerListener - 
eventi :" + eventi);

serverA.removeAsteriskServerListener(eventi);
}

@Override
public void run() {
try {
while (true) {
Log.info("ManagerAsterisk.run - state (pre sleep) :" + 
mc.getState().name() + " - " + mc.getState());

Thread.sleep(20 * 1000);
ManagerConnectionState stato = mc.getState();
Log.info("ManagerAsterisk.run - state :" + 
mc.getState().name() + " - " + mc.getState());


if (!stato.equals(ManagerConnectionState.INITIAL) && 
!stato.equals(ManagerConnectionState.CONNECTING) && 
!stato.equals(ManagerConnectionState.CONNECTED)) {

Log.info("ManagerAsterisk.run - reacreate :" + stato);
serverA = new DefaultAsteriskServer(host, user, psw);
mc = serverA.getManagerConnection();
mc.addEventListener(new ConnessioneAsterisk());
serverA.addAsteriskServerListener(eventi);
stato = mc.getState();
Log.info("ManagerAsterisk.run - reacreated :" + 
stato);

}
}
} catch (InterruptedException ex) {
Log.error("ManagerAsterisk.run" + ex, ex);
}

}
}


Il 12/11/2015 10.50, Zoumana TRAORE ha scritto:

Hi Alessio,

You probably need to share a part of the code so we can help.
I assume you did not maintain some how you AMI Connection.

Here is how i did it using PingThread provided by the AJ library

@Autowired
private PingThread pingThread;

/**
 * 
 * Connect to Asterisk Server via Live API
 * 
 * @return
 */
public void connect(){
asteriskServer = new DefaultAsteriskServer(asteriskLiveHost, 
asteriskUsername, asteriskPassword);

asteriskServer.initialize();
pingThread.addConnection(asteriskServer.getManagerConnection());
}


And you fire the PingThread for instance at your app boot-up
if(pingThread != null && !pingThread.isAlive()){
   pingThread.start();
}


Regards,
*---
*

*Zoumana TRAORE*


2015-11-12 10:28 GMT+01:00 Yves mailto:yves...@gmx.de>>:

Hi Alessio,

as my glassbowl is currently under repair, I cannot guess your
source c

Re: [Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Jhoan Orozco
Hello,

I developed an app around 1 year ago, and happened me  the same. I could
resolve this issue whith this.

When i launch my app, i do it across of a shell Script (start.sh file) but
at the begining you have to add these lines:

ulimit -u unlimited
ulimit -n 5




Your problem is when your app reaches the maximun amount of network
connections or files opened.

this my script.

#!/bin/bash
echo "Starting.."
ulimit -u unlimited
ulimit -n 5
java -cp asterisk-java.jar:. org.asteriskjava.fastagi.DefaultAgiServer &
echo "Started!"



2015-11-12 3:11 GMT-05:00 Alessio Turini :

> Dear,
> I've a problem with the class DefaultAsteriskServer and the connection
> with the Asterisk (V. 11.19.0), i'll try to explain below (and sorry for my
> english)
>
> I develop a program that links inbound call with a couple of events, I use
> the class DefaultAsteriskServer and the listener
> addAsteriskServerListener(MyClass).
> MyClass checks every call and makes different operation based on type of
> call.
> The program is ok but after 10/20 hours goes to Hollywood, this means that
> the listener not link events.
> The class DefaultAsteriskServer is declared in a static object that wrap
> it.
> I would to ask, there is a timeout of connection between Asterisk and
> DefaultAsteriskServer , can i check the connection between the two actor?
> I tried to check the state of ManagerConnection (get by
> getManagerConnection() on DefaultAsteriskServer ) but the result is always
> connected and not help me to restablished a connection.
>
> Thanks in advance, Alessio
>
>
> --
> *Dott. Alessio Turini*
> IT Dept - Credires
> Via Don Luigi Sturzo 4, Pontedera, Pisa, Italy
> +39 0587 467716 - +39 3457427943 - a.tur...@credires.it
> Le informazioni contenute in questo messaggio di posta elettronica e/o
> nel/i file/s allegato/i, sono da considerarsi strettamente riservate. Il
> loro utilizzo è consentito esclusivamente al destinatario del messaggio,
> per le finalità indicate nel messaggio stesso. Qualora riceveste questo
> messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
> darcene notizia via e-mail all'indirizzo i...@credires.it o
> telefonicamente allo +390587467700 e procedere alla distruzione del
> messaggio stesso, cancellandolo dal Vostro sistema; costituisce
> comportamento contrario ai principi dettati dal Dlgs 196/2003 il trattenere
> il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri
> soggetti, copiarlo, od utilizzarlo per finalità, diverse.
> This message and any attachments are solely for the intended recipient and
> may contain confidential or privileged information. Its use is allowed only
> to the intended recipient, for the purpose indicated in the message itself.
> If you are not the intended recipient, please notify us by email to
> i...@credires.it or by phone to +390587467700 and permanently delete this
> message and any attachments in your system. Keeping, disclosure also in
> part, distribution to other recipients, copying of the information included
> in this message and any attachments or using this information for different
> purposes is prohibited as per regulation Dlgs 196/2003.
>
>
> --
>
> ___
> Asterisk-java-users mailing list
> Asterisk-java-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users
>
>
--
___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users


Re: [Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Alessio Turini

Hi dear,
I like you, I would to be your friend :), I use 1.0.0.CI-SNAPSHOT 
and asterisk and program are in  differents hosts, some question below...

- what is the different between  Managerfactory and ServerAsterisk?
- what is the best stable library of asterisk-java?
- Is possible that Asterisk reload o restart, what is the best pratices 
to manage failure of connection? (for ServerAsterisk and ManagerFactory)


Thanks Ale



Il 12/11/2015 13.19, Yves ha scritto:

my thoughts after taking a quick look...:

I don´t see something essentially wrong... the listener only works, as 
long the object is "alive"... using it in a thread is ok, but i don´t 
see the code that initializes and finally "runs" the thread..
maybe you have deadslocks, or any other multithread related 
problems... or just a network-problem... (are asterisk and your 
programm running on different machines?)
getting the managerconnection the way you do it should work, but it 
may be better to go the recommended way (don´t know your environment) 
and use the managerfactory.

are you using at least the asterisk-java 1.0 api?
using a serverlistener does not fire much info... a 
managereventlistener would give you much more information...

maybe the thread-sleeptime of 20secs is too long...
are you sure, that your asterisk is fine all the time? maybe there are 
interference with reloads, crashes and so on? what do asterisk-logs 
say (increase verbosity or use debug log) when connections failes?
normally the managerconnection reestablishes the socketconnection, but 
this is not very stable... this only seems to work if the connection 
breaks after issuing a command... so relying on the result of getState
is quite useless... you should fire an action to reliably check the 
availability... this should of course be a command that does not 
consume much resources.. e.g. core show version etc.


yves




Am 12.11.2015 um 11:15 schrieb Alessio Turini:

Ok, thanks for the answers.
The code in answer is similar as mine, I try to insert a portion of 
project below , the class EventoAsterisk after a couple of hours(15 
h) doesn't grab the events,

There is a mode to check this type of connection?
In the method run, i try to check mc object but the result is always 
connected.

Thanks Ale


class ManagerAsterisk extends Thread {

private String host;
private String user;
private String psw;
private DefaultAsteriskServer serverA;
private ManagerConnection mc;
private EventoAsterisk eventi;

ManagerAsterisk(String host, String user, String psw) {
Log.info("DefaultAsteriskServer start ");
this.host= host;
this.user= user;
this.psw= psw;
serverA = new DefaultAsteriskServer(host, user, psw);
serverA.initialize();

mc = serverA.getManagerConnection();


}

ManagerConnection getManagerConnection() {
return serverA.getManagerConnection();
}

void addAsteriskServerListener(EventoAsterisk eventi) {
this.eventi = eventi;
serverA.addAsteriskServerListener(eventi);
}

void removeAsteriskServerListener(EventoAsterisk eventi) {
Log.info("ManagerAsterisk.removeAsteriskServerListener - 
eventi :" + eventi);

serverA.removeAsteriskServerListener(eventi);
}

@Override
public void run() {
try {
while (true) {
Log.info("ManagerAsterisk.run - state (pre sleep) :" 
+ mc.getState().name() + " - " + mc.getState());

Thread.sleep(20 * 1000);
ManagerConnectionState stato = mc.getState();
Log.info("ManagerAsterisk.run - state :" + 
mc.getState().name() + " - " + mc.getState());


if (!stato.equals(ManagerConnectionState.INITIAL) && 
!stato.equals(ManagerConnectionState.CONNECTING) && 
!stato.equals(ManagerConnectionState.CONNECTED)) {
Log.info("ManagerAsterisk.run - reacreate :" + 
stato);

serverA = new DefaultAsteriskServer(host, user, psw);
mc = serverA.getManagerConnection();
mc.addEventListener(new ConnessioneAsterisk());
serverA.addAsteriskServerListener(eventi);
stato = mc.getState();
Log.info("ManagerAsterisk.run - reacreated :" + 
stato);

}
}
} catch (InterruptedException ex) {
Log.error("ManagerAsterisk.run" + ex, ex);
}

}
}


Il 12/11/2015 10.50, Zoumana TRAORE ha scritto:

Hi Alessio,

You probably need to share a part of the code so we can help.
I assume you did not maintain some how you AMI Connection.

Here is how i did it using PingThread provided by the AJ library

@Autowired
private PingThread pingThread;

/**
 * 
 * Connect to Asterisk Server via Live API
 * 
 * @return
 */
public void connect(){
asteriskServer = new DefaultAsteriskServer(asteriskLiveHost, 
as

Re: [Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Alessio Turini

Hi,
I think this is could be a correct way, can I resolve to 
re-instance DefaultServerAsterisk in the wrapper every x time? (Patch 
solution :))
I would like to resolve this question, with an elegant solution as 
manage invariant state of DefaultServerAsterisk.

Thanks Ale


Il 12/11/2015 14.09, Jhoan Orozco ha scritto:

Hello,

I developed an app around 1 year ago, and happened me  the same. I 
could resolve this issue whith this.


When i launch my app, i do it across of a shell Script (start.sh file) 
but at the begining you have to add these lines:


ulimit -u unlimited
ulimit -n 5




Your problem is when your app reaches the maximun amount of network 
connections or files opened.


this my script.

#!/bin/bash
echo "Starting.."
ulimit -u unlimited
ulimit -n 5
java -cp asterisk-java.jar:. org.asteriskjava.fastagi.DefaultAgiServer &
echo "Started!"


2015-11-12 3:11 GMT-05:00 Alessio Turini >:


Dear,
I've a problem with the class DefaultAsteriskServer and the
connection with the Asterisk (V. 11.19.0), i'll try to explain
below (and sorry for my english)

I develop a program that links inbound call with a couple of
events, I use the class DefaultAsteriskServer and the listener
addAsteriskServerListener(MyClass).
MyClass checks every call and makes different operation based on
type of call.
The program is ok but after 10/20 hours goes to Hollywood, this
means that the listener not link events.
The class DefaultAsteriskServer is declared in a static object
that wrap it.
I would to ask, there is a timeout of connection between Asterisk
and DefaultAsteriskServer , can i check the connection between the
two actor?
I tried to check the state of ManagerConnection (get by
getManagerConnection() on DefaultAsteriskServer ) but the result
is always connected and not help me to restablished a connection.

Thanks in advance, Alessio


-- 
*Dott. Alessio Turini*

IT Dept - Credires
Via Don Luigi Sturzo 4, Pontedera, Pisa, Italy
+39 0587 467716  - +39 3457427943
 - a.tur...@credires.it

Le informazioni contenute in questo messaggio di posta elettronica
e/o nel/i file/s allegato/i, sono da considerarsi strettamente
riservate. Il loro utilizzo è consentito esclusivamente al
destinatario del messaggio, per le finalità indicate nel messaggio
stesso. Qualora riceveste questo messaggio senza esserne il
destinatario, Vi preghiamo cortesemente di darcene notizia via
e-mail all'indirizzo i...@credires.it  o
telefonicamente allo +390587467700  e
procedere alla distruzione del messaggio stesso, cancellandolo dal
Vostro sistema; costituisce comportamento contrario ai principi
dettati dal Dlgs 196/2003 il trattenere il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti,
copiarlo, od utilizzarlo per finalità, diverse.
This message and any attachments are solely for the intended
recipient and may contain confidential or privileged information.
Its use is allowed only to the intended recipient, for the purpose
indicated in the message itself. If you are not the intended
recipient, please notify us by email to i...@credires.it
 or by phone to +390587467700
 and permanently delete this message and any
attachments in your system. Keeping, disclosure also in part,
distribution to other recipients, copying of the information
included in this message and any attachments or using this
information for different purposes is prohibited as per regulation
Dlgs 196/2003.


--

___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/asterisk-java-users




--


___
Asterisk-java-users mailing list
Asterisk-java-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/asterisk-java-users


--
*Dott. Alessio Turini*
IT Dept - Credires
Via Don Luigi Sturzo 4, Pontedera, Pisa, Italy
+39 0587 467716 - +39 3457427943 - a.tur...@credires.it
Le informazioni contenute in questo messaggio di posta elettronica e/o 
nel/i file/s allegato/i, sono da considerarsi strettamente riservate. Il 
loro utilizzo è consentito esclusivamente al destinatario del messaggio, 
per le finalità indicate nel messaggio stesso. Qualora riceveste questo 
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di 
darcene notizia via e-mail all'indirizzo i...@credires.it o 
telefonicamente allo +390587467700 e procedere alla di

Re: [Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Jhoan Orozco
- what is the different between  Managerfactory and ServerAsterisk?

Well, I am not a expert in this, but i always use Managerfactory, i never
have used ServerAsterisk.

- what is the best stable library of asterisk-java?

i use asterisk-java-2.0.0.CI-20151004.214526-116.jar

its
website is:
https://nexus.reucon.com/content/repositories/opensource-snapshots/org/asteriskjava/asterisk-java/2.0.0.CI-SNAPSHOT/asterisk-java-2.0.0.CI-20151004.214526-116.jar



- Is possible that Asterisk reload o restart, what is the best pratices to
manage failure of connection? (for ServerAsterisk and ManagerFactory)

The best practice is adding these lines in you sh script launcher:

ulimit -u unlimited
ulimit -n 5


If you reload, is posible that around 15 hours next, happend the same!


I hope help  you!




2015-11-12 9:12 GMT-05:00 Alessio Turini :

> Hi dear,
> I like you, I would to be your friend :), I use  1.0.0.CI-SNAPSHOT and
> asterisk and program are in  differents hosts, some question below...
> - what is the different between  Managerfactory and ServerAsterisk?
> - what is the best stable library of asterisk-java?
> - Is possible that Asterisk reload o restart, what is the best pratices to
> manage failure of connection? (for ServerAsterisk and ManagerFactory)
>
> Thanks Ale
>
>
>
>
> Il 12/11/2015 13.19, Yves ha scritto:
>
> my thoughts after taking a quick look...:
>
> I don´t see something essentially wrong... the listener only works, as
> long the object is "alive"... using it in a thread is ok, but i don´t see
> the code that initializes and finally "runs" the thread..
> maybe you have deadslocks, or any other multithread related problems... or
> just a network-problem... (are asterisk and your programm running on
> different machines?)
> getting the managerconnection the way you do it should work, but it may be
> better to go the recommended way (don´t know your environment) and use the
> managerfactory.
> are you using at least the asterisk-java 1.0 api?
> using a serverlistener does not fire much info... a managereventlistener
> would give you much more information...
> maybe the thread-sleeptime of 20secs is too long...
> are you sure, that your asterisk is fine all the time? maybe there are
> interference with reloads, crashes and so on? what do asterisk-logs say
> (increase verbosity or use debug log) when connections failes?
> normally the managerconnection reestablishes the socketconnection, but
> this is not very stable... this only seems to work if the connection breaks
> after issuing a command... so relying on the result of getState
> is quite useless... you should fire an action to reliably check the
> availability... this should of course be a command that does not consume
> much resources.. e.g. core show version etc.
>
> yves
>
>
>
>
> Am 12.11.2015 um 11:15 schrieb Alessio Turini:
>
> Ok, thanks for the answers.
> The code in answer is similar as mine, I try to insert a portion of
> project below , the class EventoAsterisk after a couple of hours(15 h)
> doesn't grab the events,
> There is a mode to check this type of connection?
> In the method run, i try to check mc object but the result is always
> connected.
> Thanks Ale
>
>
> class ManagerAsterisk extends Thread {
>
> private String host;
> private String user;
> private String psw;
> private DefaultAsteriskServer serverA;
> private ManagerConnection mc;
> private EventoAsterisk eventi;
>
> ManagerAsterisk(String host, String user, String psw) {
> Log.info("DefaultAsteriskServer start ");
> this.host= host;
> this.user= user;
> this.psw= psw;
> serverA = new DefaultAsteriskServer(host, user, psw);
> serverA.initialize();
>
> mc = serverA.getManagerConnection();
>
>
> }
>
> ManagerConnection getManagerConnection() {
> return serverA.getManagerConnection();
> }
>
> void addAsteriskServerListener(EventoAsterisk eventi) {
> this.eventi = eventi;
> serverA.addAsteriskServerListener(eventi);
> }
>
> void removeAsteriskServerListener(EventoAsterisk eventi) {
> Log.info("ManagerAsterisk.removeAsteriskServerListener - eventi :"
> + eventi);
> serverA.removeAsteriskServerListener(eventi);
> }
>
> @Override
> public void run() {
> try {
> while (true) {
> Log.info("ManagerAsterisk.run - state (pre sleep) :" +
> mc.getState().name() + " - " + mc.getState());
> Thread.sleep(20 * 1000);
> ManagerConnectionState stato = mc.getState();
> Log.info("ManagerAsterisk.run - state :" +
> mc.getState().name() + " - " + mc.getState());
>
> if (!stato.equals(ManagerConnectionState.INITIAL) &&
> !stato.equals(ManagerConnectionState.CONNE

Re: [Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Alessio Turini

Ok thanks, the problem happens in Windows and in Linux.
What is the script for Windows?
Ale


Il 12/11/2015 15.24, Jhoan Orozco ha scritto:

- what is the different between  Managerfactory and ServerAsterisk?

Well, I am not a expert in this, but i always use Managerfactory, i 
never have used ServerAsterisk.


- what is the best stable library of asterisk-java?

i use asterisk-java-2.0.0.CI-20151004.214526-116.jar 
 its 
website is: 
https://nexus.reucon.com/content/repositories/opensource-snapshots/org/asteriskjava/asterisk-java/2.0.0.CI-SNAPSHOT/asterisk-java-2.0.0.CI-20151004.214526-116.jar




- Is possible that Asterisk reload o restart, what is the best 
pratices to manage failure of connection? (for ServerAsterisk and 
ManagerFactory)


The best practice is adding these lines in you sh script launcher:

ulimit -u unlimited
ulimit -n 5


If you reload, is posible that around 15 hours next, happend the same!


I hope help  you!




2015-11-12 9:12 GMT-05:00 Alessio Turini >:


Hi dear,
I like you, I would to be your friend :), I use
1.0.0.CI-SNAPSHOT and asterisk and program are in differents
hosts, some question below...
- what is the different between  Managerfactory and ServerAsterisk?
- what is the best stable library of asterisk-java?
- Is possible that Asterisk reload o restart, what is the best
pratices to manage failure of connection? (for ServerAsterisk and
ManagerFactory)

Thanks Ale




Il 12/11/2015 13.19, Yves ha scritto:

my thoughts after taking a quick look...:

I don´t see something essentially wrong... the listener only
works, as long the object is "alive"... using it in a thread is
ok, but i don´t see the code that initializes and finally "runs"
the thread..
maybe you have deadslocks, or any other multithread related
problems... or just a network-problem... (are asterisk and your
programm running on different machines?)
getting the managerconnection the way you do it should work, but
it may be better to go the recommended way (don´t know your
environment) and use the managerfactory.
are you using at least the asterisk-java 1.0 api?
using a serverlistener does not fire much info... a
managereventlistener would give you much more information...
maybe the thread-sleeptime of 20secs is too long...
are you sure, that your asterisk is fine all the time? maybe
there are interference with reloads, crashes and so on? what do
asterisk-logs say (increase verbosity or use debug log) when
connections failes?
normally the managerconnection reestablishes the
socketconnection, but this is not very stable... this only seems
to work if the connection breaks after issuing a command... so
relying on the result of getState
is quite useless... you should fire an action to reliably check
the availability... this should of course be a command that does
not consume much resources.. e.g. core show version etc.

yves




Am 12.11.2015 um 11:15 schrieb Alessio Turini:

Ok, thanks for the answers.
The code in answer is similar as mine, I try to insert a portion
of project below , the class EventoAsterisk after a couple of
hours(15 h) doesn't grab the events,
There is a mode to check this type of connection?
In the method run, i try to check mc object but the result is
always connected.
Thanks Ale


class ManagerAsterisk extends Thread {

private String host;
private String user;
private String psw;
private DefaultAsteriskServer serverA;
private ManagerConnection mc;
private EventoAsterisk eventi;

ManagerAsterisk(String host, String user, String psw) {
Log.info("DefaultAsteriskServer start ");
this.host= host;
this.user= user;
this.psw= psw;
serverA = new DefaultAsteriskServer(host, user, psw);
serverA.initialize();

mc = serverA.getManagerConnection();


}

ManagerConnection getManagerConnection() {
return serverA.getManagerConnection();
}

void addAsteriskServerListener(EventoAsterisk eventi) {
this.eventi = eventi;
serverA.addAsteriskServerListener(eventi);
}

void removeAsteriskServerListener(EventoAsterisk eventi) {
Log.info("ManagerAsterisk.removeAsteriskServerListener - eventi
:" + eventi);
serverA.removeAsteriskServerListener(eventi);
}

@Override
public void run() {
try {
while (true) {
Log.info("ManagerAsterisk.run - state (pre
sleep) :" + mc.getState().name() + " - " + mc.getState());
Thr

Re: [Asterisk-java-users] DefaultAsteriskServer goes to Hollywood

2015-11-12 Thread Jhoan Orozco
Onli for linux.


i never have used Asterisk in Windows, is not recommended.

2015-11-12 9:35 GMT-05:00 Alessio Turini :

> Ok thanks, the problem happens in Windows and in Linux.
> What is the script for Windows?
> Ale
>
>
>
> Il 12/11/2015 15.24, Jhoan Orozco ha scritto:
>
> - what is the different between  Managerfactory and ServerAsterisk?
>
> Well, I am not a expert in this, but i always use Managerfactory, i never
> have used ServerAsterisk.
>
> - what is the best stable library of asterisk-java?
>
> i use asterisk-java-2.0.0.CI-20151004.214526-116.jar
> 
>  its
> website is:
> https://nexus.reucon.com/content/repositories/opensource-snapshots/org/asteriskjava/asterisk-java/2.0.0.CI-SNAPSHOT/asterisk-java-2.0.0.CI-20151004.214526-116.jar
>
>
>
> - Is possible that Asterisk reload o restart, what is the best pratices to
> manage failure of connection? (for ServerAsterisk and ManagerFactory)
>
> The best practice is adding these lines in you sh script launcher:
>
> ulimit -u unlimited
> ulimit -n 5
>
>
> If you reload, is posible that around 15 hours next, happend the same!
>
>
> I hope help  you!
>
>
>
>
> 2015-11-12 9:12 GMT-05:00 Alessio Turini :
>
>> Hi dear,
>> I like you, I would to be your friend :), I use  1.0.0.CI-SNAPSHOT
>> and asterisk and program are in  differents hosts, some question below...
>> - what is the different between  Managerfactory and ServerAsterisk?
>> - what is the best stable library of asterisk-java?
>> - Is possible that Asterisk reload o restart, what is the best pratices
>> to manage failure of connection? (for ServerAsterisk and ManagerFactory)
>>
>> Thanks Ale
>>
>>
>>
>>
>> Il 12/11/2015 13.19, Yves ha scritto:
>>
>> my thoughts after taking a quick look...:
>>
>> I don´t see something essentially wrong... the listener only works, as
>> long the object is "alive"... using it in a thread is ok, but i don´t see
>> the code that initializes and finally "runs" the thread..
>> maybe you have deadslocks, or any other multithread related problems...
>> or just a network-problem... (are asterisk and your programm running on
>> different machines?)
>> getting the managerconnection the way you do it should work, but it may
>> be better to go the recommended way (don´t know your environment) and use
>> the managerfactory.
>> are you using at least the asterisk-java 1.0 api?
>> using a serverlistener does not fire much info... a managereventlistener
>> would give you much more information...
>> maybe the thread-sleeptime of 20secs is too long...
>> are you sure, that your asterisk is fine all the time? maybe there are
>> interference with reloads, crashes and so on? what do asterisk-logs say
>> (increase verbosity or use debug log) when connections failes?
>> normally the managerconnection reestablishes the socketconnection, but
>> this is not very stable... this only seems to work if the connection breaks
>> after issuing a command... so relying on the result of getState
>> is quite useless... you should fire an action to reliably check the
>> availability... this should of course be a command that does not consume
>> much resources.. e.g. core show version etc.
>>
>> yves
>>
>>
>>
>>
>> Am 12.11.2015 um 11:15 schrieb Alessio Turini:
>>
>> Ok, thanks for the answers.
>> The code in answer is similar as mine, I try to insert a portion of
>> project below , the class EventoAsterisk after a couple of hours(15 h)
>> doesn't grab the events,
>> There is a mode to check this type of connection?
>> In the method run, i try to check mc object but the result is always
>> connected.
>> Thanks Ale
>>
>>
>> class ManagerAsterisk extends Thread {
>>
>> private String host;
>> private String user;
>> private String psw;
>> private DefaultAsteriskServer serverA;
>> private ManagerConnection mc;
>> private EventoAsterisk eventi;
>>
>> ManagerAsterisk(String host, String user, String psw) {
>> Log.info("DefaultAsteriskServer start ");
>> this.host= host;
>> this.user= user;
>> this.psw= psw;
>> serverA = new DefaultAsteriskServer(host, user, psw);
>> serverA.initialize();
>>
>> mc = serverA.getManagerConnection();
>>
>>
>> }
>>
>> ManagerConnection getManagerConnection() {
>> return serverA.getManagerConnection();
>> }
>>
>> void addAsteriskServerListener(EventoAsterisk eventi) {
>> this.eventi = eventi;
>> serverA.addAsteriskServerListener(eventi);
>> }
>>
>> void removeAsteriskServerListener(EventoAsterisk eventi) {
>> Log.info("ManagerAsterisk.removeAsteriskServerListener - eventi
>> :" + eventi);
>> serverA.removeAsteriskServerListener(eventi);
>> }
>>
>> @Override
>> public void run() {
>> try {
>> while (true) {
>> Log.info("M