Hi Pedro,
first, please ask for support on the asterisk-users mailing list so
others can benefit from your question, too.
http://asterisk-java.org/development/mail-lists.html
Regarding your question:
You are sending actions from the manager event thread which causes a
deadlock that's why you get the TimeoutException.
You must either send the action from a different thread or just use the
live API (look for DefaultAsteriskServer) that also allows watching for
events and reading variables at a higher level that takes care of the
low level threading issues.
=3DStefan
Pedro J. Romero wrote:
> Dear Stefan:
>=20
> =20
>=20
> First of all, thank you very much for your great job. I=E2=80=99m Pedro=
Romero
> from Iten, S.L. in Spain. We are a little company of software developer=
s
> and asterisk integrators, and we are using asterisk-java to make a
> little interface to asterisk.
>=20
> =20
>=20
> Perhaps you can help us with a little problem we have encountered: we
> want to read a variable from a channel, and when we try to do it, Java
> throws a TimeOutException. We have no look so deep, I=E2=80=99ve though=
t the
> best would be to write to you first.
>=20
> =20
>=20
> The code is this:
>=20
> =20
>=20
> *public* *void* onManagerEvent(ManagerEvent event){
>=20
> String cliente=3D"";
>=20
> ManagerResponse response=3D*new* ManagerResponse();
>=20
> *if*(event.getClass().getSimpleName().equals("JoinEvent")){=
>=20
> JoinEvent ev=3D(JoinEvent)event;
>=20
> *try*{
>=20
> GetVarAction getVarAction =3D *new* GetVarActio=
n();
>=20
> getVarAction.setChannel(ev.getChannel());
>=20
> getVarAction.setVariable("CLIENTE");
>=20
> response =3D
> parent.getManager().sendAction(getVarAction); =C3=9F parent is the inst=
ance
> where inside which the managerConnection is declared.
>=20
> cliente =3D response.getAttribute("Value");
>=20
> }
>=20
> *catch*(TimeoutException exc){System./out/.println("Tiempo
> de espera agotado");}
>=20
> *catch*(IOException exc){System./out/.println("Error de I/O=
");}
>=20
> ...
>=20
> ...
>=20
> }
>=20
> =20
>=20
> We have tried to increase the timeout (with a second argument to the
> method sendAction) without success. I think I=E2=80=99ve read somewhere=
that
> there was a problem with timeout and responses coming to fast, solved i=
n
> 0.3-m1. We are trying 0.3-m2.
>=20
> =20
>=20
> If you tell me that the code is the good one, we will going into deep t=
o
> look for any bug, and we will inform you if we find something.
>=20
> =20
>=20
> Advanced thanks, and congratulations again for your work.
>=20
> =20
>=20
> Pedro J. Romero.
>=20
> Iten, S.L.
>=20
--=20
reuter network consulting
Neusser Str. 110
50760 Koeln
Germany
Telefon: +49 221 1305699-0
Telefax: +49 221 1305699-90
E-Mail: ste...@re...
Jabber: ste...@re...
Steuernummern 215/5140/1791 USt-IdNr. DE220701760
|