Thread: [Asterisk-java-users] Re: Timeout when hanging up
Brought to you by:
srt
From: <be...@mo...> - 2006-01-12 13:17:41
|
Hello! I'm trying to do exactly the same thing as in the Timeout when hanging up topic. The difference is that instead of SIP, I want to use Zap channels (well zap compatible aculab card). I have a problem with receiving events to the call manager. What I'm trying to do is to call a phone, and as soon as I get a ringing tone, I want to hangup. Therefore I'm trying to get the NewChannelEvent with state ringing. 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. I can see in the asterisk console that the card event is occuring, and the card driver then sends AST_CONTROL_RINGING to the asterisk queue. Ufortulately the event is not passed by the call manager. The only events that are sent are: net.sf.asterisk.manager.event.NewChannelEvent, State:Down net.sf.asterisk.manager.event.NewCallerIdEvent net.sf.asterisk.manager.event.HangupEvent net.sf.asterisk.manager.event.OriginateFailureEvent net.sf.asterisk.manager.event.DisconnectEvent When I'm calling using local SIP phone, the events go through: net.sf.asterisk.manager.event.NewChannelEvent: State: Down net.sf.asterisk.manager.event.NewCallerIdEvent: net.sf.asterisk.manager.event.NewChannelEvent: State: Ringing net.sf.asterisk.manager.event.HangupEvent: net.sf.asterisk.manager.event.PeerStatusEvent: Is there some configuration file in asterisk that needs to be changed in order for zap channels to report the NewChannelEvent every time? -- 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... |
From: Stefan R. <sr...@re...> - 2006-01-15 03:06:21
|
On Thu, 2006-01-12 at 14:13 +0100, Robert Krzymi=F1ski wrote: > When I use SIP, everything is fine, the event shows up just like it=20 > should, but when I'm using a SIP VOIP provider or a Zap (aculab) card,=20 > 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? =3DStefan |
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... |
From: Stefan R. <sr...@re...> - 2006-01-18 13:25:02
Attachments:
signature.asc
|
Robert, thanks for your clarification. It seems it only works if the phone is local to Asterisk, i.e. directly connected. Is this correct? I am not sure if it is a bug that Asterisk does not generate "Ringing" events for those channels or if its the desired behaviour. In any case i doubt its an Asterisk-Java specific problem so its probably best to either post it to the asterisk-useres list or report it as a bug on Asterisk's bug tracker. =Stefan |
From: <be...@mo...> - 2006-01-18 13:48:47
|
Użytkownik Stefan Reuter napisał: > Robert, > > thanks for your clarification. It seems it only works if the phone is > local to Asterisk, i.e. directly connected. Is this correct? Hey! That's a bright conclusion! > I am not sure if it is a bug that Asterisk does not generate "Ringing" > events for those channels or if its the desired behaviour. In any case i > doubt its an Asterisk-Java specific problem so its probably best to > either post it to the asterisk-useres list or report it as a bug on > Asterisk's bug tracker. OK! I'll do just that then. > > =Stefan 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... |