Re: [Asterisk-java-users] Re: Timeout when hanging up
Brought to you by:
srt
From: <be...@mo...> - 2006-01-16 10:05:51
|
Hello! > On Thu, 2006-01-12 at 14:13 +0100, Robert Krzymiński wrote: > >>When I use SIP, everything is fine, the event shows up just like it >>should, but when I'm using a SIP VOIP provider or a Zap (aculab) card, >>the event is not comming to the call manager. > > > what do you mean by "when i use sip its fine but when i am using a sip > voip provider it is not"? isnt a sip voip provider sip, too? > > could it be that the difference between the cases when it works and when > not is that you are sometimes looking at incoming channels and sometimes > at outgoing? OK here's what I'm doing: The idea is to check the regular phones, by calling them and hanging up as they start ringing, so we're talking about outgoing calls. Now, there are 3 cases: - SIP to SIP (a software phone), - calling regular phones using a VoIP provider over SIP, - calling regular phones using Aculab card (based on Zaptel), over E1 line using Q.931 protocol. Cases 1 and 2 are just for testing. So far, the only case that works is the first one (the NewChannelEvent reaches the call manager). In the other cases, the event does not reach the call manager. As for the case 3 I can see that the card sends the event to the asterisk. The card driver uses the ast_queue_control function to send the event to the asterisk event queue, so I guess that's fine. Here's the code that I'm using in lava: import java.io.IOException; import java.util.Date; import net.sf.asterisk.fastagi.command.AnswerCommand; import net.sf.asterisk.fastagi.command.ChannelStatusCommand; import net.sf.asterisk.fastagi.command.ExecCommand; import net.sf.asterisk.fastagi.command.GetVariableCommand; import net.sf.asterisk.manager.AuthenticationFailedException; import net.sf.asterisk.manager.Call; import net.sf.asterisk.manager.Channel; import net.sf.asterisk.manager.DefaultAsteriskManager; import net.sf.asterisk.manager.ManagerConnection; import net.sf.asterisk.manager.ManagerConnectionFactory; import net.sf.asterisk.manager.ManagerEventHandler; import net.sf.asterisk.manager.ManagerResponseHandler; import net.sf.asterisk.manager.Originate; import net.sf.asterisk.manager.TimeoutException; import net.sf.asterisk.manager.action.EventsAction; import net.sf.asterisk.manager.action.HangupAction; import net.sf.asterisk.manager.action.OriginateAction; import net.sf.asterisk.manager.action.StatusAction; import net.sf.asterisk.manager.event.ChannelEvent; import net.sf.asterisk.manager.event.ManagerEvent; import net.sf.asterisk.manager.event.NewChannelEvent; import net.sf.asterisk.manager.event.NewStateEvent; import net.sf.asterisk.manager.response.ManagerResponse; public class HelloEvents implements ManagerEventHandler { private ManagerConnection managerConnection; public HelloEvents() throws IOException { ManagerConnectionFactory factory = new ManagerConnectionFactory(); //217.114.117.249 this.managerConnection = "host", "manager", "pa55w0rd"); } public void run() throws IOException, AuthenticationFailedException, TimeoutException, InterruptedException { managerConnection.login(); // register for events managerConnection.addEventHandler(this); OriginateAction originateAction; ManagerResponse originateResponse; String phoneNumber = "124332432"; originateAction = new OriginateAction(); originateAction.setCallerId("\"bercik\" <123143255>"); originateAction.setApplication("Wait"); originateAction.setData("1"); originateAction.setTimeout((Long.valueOf("30300"))); originateAction.setAsync(new Boolean(true)); try { //Using sip works fine //originateAction.setChannel("SIP/bercik"); originateAction.setChannel("Aculab/1/"+phoneNumber); // send the originate action and wait for a maximum of // 30 seconds for Asterisk to send a reply originateResponse = managerConnection.sendAction(originateAction,30000); } catch (TimeoutException e) { e.printStackTrace(); } // wait 10 seconds for events to come in Thread.sleep(30000); // and finally log off and disconnect managerConnection.logoff(); } public void handleEvent(ManagerEvent event) { // just print received events System.out.println(event.toString()); if (event instanceof NewChannelEvent) { NewChannelEvent cevent = (NewChannelEvent) event; System.out.println(cevent.getState()); if (cevent.getState().compareToIgnoreCase("Ringing") == 0) { System.out.println("Got ringing, hanging up"); HangupAction hangup = new HangupAction(); hangup.setChannel(cevent.getChannel()); try { managerConnection.sendAction(hangup, null); } catch (Exception e) { e.printStackTrace(); } } } } public static void main(String[] args) throws Exception { HelloEvents helloEvents; helloEvents = new HelloEvents(); helloEvents.run(); } } Now, what happens is, the phone is just ringing and I can answer, but no NewChannelEvent is comming, when the phone is ringing. Any ideas, on why is this happening? Thanks. -- Robert Krzyminski Mobiteam Sp. z o.o. ul. Rynek Glowny 6, 31-042 Krakow, Poland tel: +48 22 372 63 42 ICQ #: 25467968 e-mail: rob...@mo... |