Thread: Re: [Asterisk-java-users] "MonitorAction" always 'Exceeds TimeOut'
Brought to you by:
srt
From: Jose B. <pe...@gm...> - 2014-01-09 18:16:39
|
OK. I found the problem. If I use "managerconnection" as Eventlistener I cannot sendAction with it. I had to create a second "managerconnection without EventListener ManagerConnectionFactory factory = new ManagerConnectionFactory(...) this.managerConnection = factory.createManagerConnection(); ManagerConnectionFactory factory_2 = new ManagerConnectionFactory(...) this.managerConnection_2 = factory_2.createManagerConnection(); Should I create a second 'factory' as well or would it be enough with: ManagerConnectionFactory factory = new ManagerConnectionFactory(...) this.managerConnection = factory.createManagerConnection(); this.managerConnection_2 = factory.createManagerConnection(); On 3 January 2014 11:05, Jose Baez <pe...@gm...> wrote: > Oops! I receive "timeout exceed" exception for every Action. :((( > > Maybe my code is not properly written to handle Actions and their > responsess..... > > When I receive a specfic event I want to send an Action, but everytime I > "sendAction" it is a "timeout" exception. > > I'm running my program as: > > public void run() throws IOException, AuthenticationFailedException, > TimeoutException, InterruptedException { > > managerConnection.addEventListener(this); > managerConnection.login(); > > while (running) { > Thread.sleep(5000); > } > > managerConnection.logoff(); > } > > @Override > public void *onManagerEvent(ManagerEvent event)* { > > // If event is NewExtenEvent... > if (event.getClass() == NewExtenEvent.class) { > handleEvent((NewExtenEvent) event); > } > // If event is NewChannel... > else if ((event.getClass() == NewChannelEvent.class)) { > handleEvent((NewChannelEvent) event); > } > } > > Sometimes I "sendAction" in NewExtenEvent (with the code sent in the > previous email). > > > > > On 2 January 2014 17:01, Jose Baez <pe...@gm...> wrote: > >> Hi! >> >> I've been struggling a bit with >> asterisk-java-1.0.0.CI-20140101.jar (January 1st, 2014) and Asterisk v11.5 >> >> Whenever I run *"MonitorAction"* Asterisk-java replies with "TimeOut >> Exceed" exception, but Asterisk is recording OK. >> Same exception happens with "StopMonitor". >> >> try { >> managerConnection.sendAction(*new MonitorAction*(channel, >> filename, "WAV", true)); >> >> // Forcing a timeout still pops exception. >> //managerConnection.sendAction(*new MonitorAction*(channel, >> filename, "WAV", true), 1000); >> >> } catch (IOException ex) { >> System.out.println(ex); >> } catch (TimeoutException ex) { >> System.out.println(ex); >> } catch (IllegalArgumentException ex) { >> System.out.println(ex); >> } catch (IllegalStateException ex) { >> System.out.println(ex); >> } >> >> >> Any idea? >> > > |
From: Максим Б. <bui...@gm...> - 2014-01-11 17:02:48
|
Hi! it's very strange. I use the one Manager connection for listen the events and send some actions. 2014/1/9 Jose Baez <pe...@gm...> > OK. I found the problem. > > If I use "managerconnection" as Eventlistener I cannot sendAction with it. > > I had to create a second "managerconnection without EventListener > > > ManagerConnectionFactory factory = new > ManagerConnectionFactory(...) > this.managerConnection = factory.createManagerConnection(); > > ManagerConnectionFactory factory_2 = new > ManagerConnectionFactory(...) > this.managerConnection_2 = factory_2.createManagerConnection(); > > > Should I create a second 'factory' as well or would it be enough with: > > ManagerConnectionFactory factory = new ManagerConnectionFactory(...) > > this.managerConnection = factory.createManagerConnection(); > this.managerConnection_2 = factory.createManagerConnection(); > > > On 3 January 2014 11:05, Jose Baez <pe...@gm...> wrote: > >> Oops! I receive "timeout exceed" exception for every Action. :((( >> >> Maybe my code is not properly written to handle Actions and their >> responsess..... >> >> When I receive a specfic event I want to send an Action, but everytime I >> "sendAction" it is a "timeout" exception. >> >> I'm running my program as: >> >> public void run() throws IOException, AuthenticationFailedException, >> TimeoutException, InterruptedException { >> >> managerConnection.addEventListener(this); >> managerConnection.login(); >> >> while (running) { >> Thread.sleep(5000); >> } >> >> managerConnection.logoff(); >> } >> >> @Override >> public void *onManagerEvent(ManagerEvent event)* { >> >> // If event is NewExtenEvent... >> if (event.getClass() == NewExtenEvent.class) { >> handleEvent((NewExtenEvent) event); >> } >> // If event is NewChannel... >> else if ((event.getClass() == NewChannelEvent.class)) { >> handleEvent((NewChannelEvent) event); >> } >> } >> >> Sometimes I "sendAction" in NewExtenEvent (with the code sent in the >> previous email). >> >> >> >> >> On 2 January 2014 17:01, Jose Baez <pe...@gm...> wrote: >> >>> Hi! >>> >>> I've been struggling a bit with >>> asterisk-java-1.0.0.CI-20140101.jar (January 1st, 2014) and Asterisk v11.5 >>> >>> Whenever I run *"MonitorAction"* Asterisk-java replies with "TimeOut >>> Exceed" exception, but Asterisk is recording OK. >>> Same exception happens with "StopMonitor". >>> >>> try { >>> managerConnection.sendAction(*new MonitorAction*(channel, >>> filename, "WAV", true)); >>> >>> // Forcing a timeout still pops exception. >>> //managerConnection.sendAction(*new MonitorAction*(channel, >>> filename, "WAV", true), 1000); >>> >>> } catch (IOException ex) { >>> System.out.println(ex); >>> } catch (TimeoutException ex) { >>> System.out.println(ex); >>> } catch (IllegalArgumentException ex) { >>> System.out.println(ex); >>> } catch (IllegalStateException ex) { >>> System.out.println(ex); >>> } >>> >>> >>> Any idea? >>> >> >> > > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > |
From: Yves A. <yv...@gm...> - 2014-01-11 19:15:00
|
Hi, I think it may not be a good idea to fire non-asynchronous actions from within a captured event... you should try to fire those events in an own thread so that there won´t be any blocking problems. I did not check this out, but it may be, that MonitorAction does not return before recording is complete... this would also be no problem if the monitoraction was fired in an own thread... yves Am 11.01.2014 18:02, schrieb ?????? ??????: > Hi! it's very strange. I use the one Manager connection for listen the > events and send some actions. > > > 2014/1/9 Jose Baez <pe...@gm... <mailto:pe...@gm...>> > > OK. I found the problem. > > If I use "managerconnection" as Eventlistener I cannot sendAction > with it. > > I had to create a second "managerconnection without EventListener > > > ManagerConnectionFactory factory = new ManagerConnectionFactory(...) > this.managerConnection = factory.createManagerConnection(); > ManagerConnectionFactory factory_2 = new > ManagerConnectionFactory(...) > this.managerConnection_2 = factory_2.createManagerConnection(); > > > Should I create a second 'factory' as well or would it be enough with: > > ManagerConnectionFactory factory = new ManagerConnectionFactory(...) > > this.managerConnection = factory.createManagerConnection(); > this.managerConnection_2 = factory.createManagerConnection(); > > > On 3 January 2014 11:05, Jose Baez <pe...@gm... > <mailto:pe...@gm...>> wrote: > > Oops! I receive "timeout exceed" exception for every Action. :((( > > Maybe my code is not properly written to handle Actions and > their responsess..... > > When I receive a specfic event I want to send an Action, but > everytime I "sendAction" it is a "timeout" exception. > > I'm running my program as: > > public void run() throws IOException, > AuthenticationFailedException, > TimeoutException, InterruptedException { > > managerConnection.addEventListener(this); > managerConnection.login(); > > while (running) { > Thread.sleep(5000); > } > > managerConnection.logoff(); > } > > @Override > public void *onManagerEvent(ManagerEvent event)* { > > // If event is NewExtenEvent... > if (event.getClass() == NewExtenEvent.class) { > handleEvent((NewExtenEvent) event); > } > // If event is NewChannel... > else if ((event.getClass() == NewChannelEvent.class)) { > handleEvent((NewChannelEvent) event); > } > } > > Sometimes I "sendAction" in NewExtenEvent (with the code sent > in the previous email). > > > > > On 2 January 2014 17:01, Jose Baez <pe...@gm... > <mailto:pe...@gm...>> wrote: > > Hi! > > I've been struggling a bit with > asterisk-java-1.0.0.CI-20140101.jar (January 1st, 2014) > and Asterisk v11.5 > > Whenever I run *"MonitorAction"* Asterisk-java replies > with "TimeOut Exceed" exception, but Asterisk is recording OK. > Same exception happens with "StopMonitor". > > try { > managerConnection.sendAction(*new MonitorAction*(channel, > filename, "WAV", true)); > > // Forcing a timeout still pops exception. > //managerConnection.sendAction(*new > MonitorAction*(channel, filename, "WAV", true), 1000); > > } catch (IOException ex) { > System.out.println(ex); > } catch (TimeoutException ex) { > System.out.println(ex); > } catch (IllegalArgumentException ex) { > System.out.println(ex); > } catch (IllegalStateException ex) { > System.out.println(ex); > } > > > Any idea? > > > > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > <mailto:Ast...@li...> > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users |
From: Jose B. <pe...@gm...> - 2014-01-11 20:51:52
|
Thanks Yves. It is not only "MonitorAction", every Action runs with "timeout exception" although they are executed correctly. Shall I create a Thread like this? protected void handleEvent(NewExtenEvent extevent) { if (exteevent == "something") { // Create new Thread to MonitorAction using same "managerconnection" sendMonitorAction = new Thread() { public void run() { try { managerResponse = managerConnection.sendAction(new MonitorAction(channel, filename, "WAV", true)); } catch(all catches) {} } }; // end_ new_Thread sendMonitorAction.start(); } // end_if } On 11 January 2014 19:14, Yves A. <yv...@gm...> wrote: > Hi, > > I think it may not be a good idea to fire non-asynchronous actions from > within a captured event... you should try to > fire those events in an own thread so that there won´t be any blocking > problems. > I did not check this out, but it may be, that MonitorAction does not > return before recording is complete... this would > also be no problem if the monitoraction was fired in an own thread... > > yves > > Am 11.01.2014 18:02, schrieb Максим Буйлин: > > Hi! it's very strange. I use the one Manager connection for listen the > events and send some actions. > > > 2014/1/9 Jose Baez <pe...@gm...> > >> OK. I found the problem. >> >> If I use "managerconnection" as Eventlistener I cannot sendAction with >> it. >> >> I had to create a second "managerconnection without EventListener >> >> >> ManagerConnectionFactory factory = new >> ManagerConnectionFactory(...) >> this.managerConnection = factory.createManagerConnection(); >> >> ManagerConnectionFactory factory_2 = new >> ManagerConnectionFactory(...) >> this.managerConnection_2 = factory_2.createManagerConnection(); >> >> >> Should I create a second 'factory' as well or would it be enough with: >> >> ManagerConnectionFactory factory = new ManagerConnectionFactory(...) >> >> this.managerConnection = factory.createManagerConnection(); >> this.managerConnection_2 = factory.createManagerConnection(); >> >> >> On 3 January 2014 11:05, Jose Baez <pe...@gm...> wrote: >> >>> Oops! I receive "timeout exceed" exception for every Action. :((( >>> >>> Maybe my code is not properly written to handle Actions and their >>> responsess..... >>> >>> When I receive a specfic event I want to send an Action, but everytime >>> I "sendAction" it is a "timeout" exception. >>> >>> I'm running my program as: >>> >>> public void run() throws IOException, AuthenticationFailedException, >>> TimeoutException, InterruptedException { >>> >>> managerConnection.addEventListener(this); >>> managerConnection.login(); >>> >>> while (running) { >>> Thread.sleep(5000); >>> } >>> >>> managerConnection.logoff(); >>> } >>> >>> @Override >>> public void *onManagerEvent(ManagerEvent event)* { >>> >>> // If event is NewExtenEvent... >>> if (event.getClass() == NewExtenEvent.class) { >>> handleEvent((NewExtenEvent) event); >>> } >>> // If event is NewChannel... >>> else if ((event.getClass() == NewChannelEvent.class)) { >>> handleEvent((NewChannelEvent) event); >>> } >>> } >>> >>> Sometimes I "sendAction" in NewExtenEvent (with the code sent in the >>> previous email). >>> >>> >>> >>> >>> On 2 January 2014 17:01, Jose Baez <pe...@gm...> wrote: >>> >>>> Hi! >>>> >>>> I've been struggling a bit with >>>> asterisk-java-1.0.0.CI-20140101.jar (January 1st, 2014) and Asterisk v11.5 >>>> >>>> Whenever I run *"MonitorAction"* Asterisk-java replies with "TimeOut >>>> Exceed" exception, but Asterisk is recording OK. >>>> Same exception happens with "StopMonitor". >>>> >>>> try { >>>> managerConnection.sendAction(*new MonitorAction*(channel, >>>> filename, "WAV", true)); >>>> >>>> // Forcing a timeout still pops exception. >>>> //managerConnection.sendAction(*new MonitorAction*(channel, >>>> filename, "WAV", true), 1000); >>>> >>>> } catch (IOException ex) { >>>> System.out.println(ex); >>>> } catch (TimeoutException ex) { >>>> System.out.println(ex); >>>> } catch (IllegalArgumentException ex) { >>>> System.out.println(ex); >>>> } catch (IllegalStateException ex) { >>>> System.out.println(ex); >>>> } >>>> >>>> >>>> Any idea? >>>> >>> >>> >> >> >> ------------------------------------------------------------------------------ >> CenturyLink Cloud: The Leader in Enterprise Cloud Services. >> Learn Why More Businesses Are Choosing CenturyLink Cloud For >> Critical Workloads, Development Environments & Everything In Between. >> Get a Quote or Start a Free Trial Today. >> >> http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk >> _______________________________________________ >> Asterisk-java-users mailing list >> Ast...@li... >> https://lists.sourceforge.net/lists/listinfo/asterisk-java-users >> >> > > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > > > > _______________________________________________ > Asterisk-java-users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > > > > ------------------------------------------------------------------------------ > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users > > |