Thread: [Asterisk-java-users] Originating calls for automatic messaging
Brought to you by:
srt
From: Carlos G M. <tr...@ac...> - 2006-09-29 01:41:06
|
Hi, I'm new to the manager interface, and I'm stumbling on how to do something that I thought was going to be much easier :( I've to dial a list of numbers and pass a message on connecting. I have to audit # of calls, connetions and failures. After some thinking, I was thinking about "originatingToExtension" from a "virtual" channel and on answering, redirecting that to the extension which is head of the message/service. Like: <extensions.conf> ... [dialing] exten => 0,1,Answer exten => 0,n,Wait,60 and originateToExtension("Local/0@dialing","dialout","<dest_no>",1,25000); But this is not behaving as I expected. It returns before the call is connected, failures are not correctly typed, etc. What is the right way (or a working one) of doing this ? -Carlos -- Carlos G Mendioroz <tr...@ac...> |
From: Stefan R. <ste...@re...> - 2006-09-29 11:11:36
Attachments:
signature.asc
|
Did you try it the other way round, i.e. originateToExtension("Local/dest_no@dialout","dialing","0",1,25000); This would call dest_no and when answered connect to your extension. =3DStefan Carlos G Mendioroz wrote: > Hi, > I'm new to the manager interface, and I'm stumbling on how to do > something that I thought was going to be much easier :( >=20 > I've to dial a list of numbers and pass a message on connecting. > I have to audit # of calls, connetions and failures. >=20 > After some thinking, I was thinking about "originatingToExtension" > from a "virtual" channel and on answering, redirecting that to > the extension which is head of the message/service. >=20 > Like: > <extensions.conf> > ... > [dialing] > exten =3D> 0,1,Answer > exten =3D> 0,n,Wait,60 >=20 > and > originateToExtension("Local/0@dialing","dialout","<dest_no>",1,25000); >=20 > But this is not behaving as I expected. It returns before the call is > connected, failures are not correctly typed, etc. >=20 > What is the right way (or a working one) of doing this ? >=20 > -Carlos --=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... |
From: Carlos G M. <tr...@ac...> - 2006-09-29 14:53:32
|
Yes, and it sort of works, but I don't get access to the failure conditions. (i.e. Busy becomes channel unavailable) :( Hmm, I thought it was going to be an easy one ... -Carlos Stefan Reuter @ 29/09/2006 08:11 -0300 dixit: > Did you try it the other way round, i.e. > originateToExtension("Local/dest_no@dialout","dialing","0",1,25000); > > This would call dest_no and when answered connect to your extension. > > =Stefan > > Carlos G Mendioroz wrote: >> Hi, >> I'm new to the manager interface, and I'm stumbling on how to do >> something that I thought was going to be much easier :( >> >> I've to dial a list of numbers and pass a message on connecting. >> I have to audit # of calls, connetions and failures. >> >> After some thinking, I was thinking about "originatingToExtension" >> from a "virtual" channel and on answering, redirecting that to >> the extension which is head of the message/service. >> >> Like: >> <extensions.conf> >> ... >> [dialing] >> exten => 0,1,Answer >> exten => 0,n,Wait,60 >> >> and >> originateToExtension("Local/0@dialing","dialout","<dest_no>",1,25000); >> >> But this is not behaving as I expected. It returns before the call is >> connected, failures are not correctly typed, etc. >> >> What is the right way (or a working one) of doing this ? >> >> -Carlos > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > ------------------------------------------------------------------------ > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users -- Carlos G Mendioroz <tr...@ac...> |
From: Stefan R. <ste...@re...> - 2006-09-29 14:58:41
Attachments:
signature.asc
|
Carlos G Mendioroz wrote: > Yes, and it sort of works, but I don't get access to the failure > conditions. (i.e. Busy becomes channel unavailable) :( >=20 > Hmm, I thought it was going to be an easy one ... no. detecting the cause for a failure is one of the most complicated things with the originate stuff and the current implementation in Asterisk-Java is probably far from excellent in this regard. You can do me a favor and provide me with a detailed description of the situations (i.e. what you did in your code and whether the caller/callee is busy an), a dump of the events received through the Manager API (see http://asterisk-java.org/page/aj?entry=3Ddebugging_manager_api) and the logs. Then I can further investigate and possibly enhance the detection. =3DStefan --=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... |
From: Carlos G M. <tr...@ac...> - 2006-09-29 15:24:18
|
Stefan Reuter @ 29/09/2006 11:58 -0300 dixit: > Carlos G Mendioroz wrote: >> Yes, and it sort of works, but I don't get access to the failure >> conditions. (i.e. Busy becomes channel unavailable) :( >> >> Hmm, I thought it was going to be an easy one ... > > no. detecting the cause for a failure is one of the most complicated > things with the originate stuff and the current implementation in > Asterisk-Java is probably far from excellent in this regard. > You can do me a favor and provide me with a detailed description of the > situations (i.e. what you did in your code and whether the caller/callee > is busy an), a dump of the events received through the Manager API (see > http://asterisk-java.org/page/aj?entry=debugging_manager_api) and the > logs. Then I can further investigate and possibly enhance the detection. > > =Stefan Ok, no problem, I'll try to do that, but first let me get clear which way "should" I be doing this: The originate command gets a channel and a destination, which could be a context/extension or an application. My idea was that the reporting would be about the action involved in doing this connection and not in the creation of the involved channel. But in fact, I'm interested in the "real" call leg and the "loopback" was just that, a virtual channel to make the framework work. So I'm going to do: originateToExtension("Local/dest@dialout","dialing","0",1,timeout); redirect("service", "srv_no", 1); Or use the asynch model and get the different completion states. Right ? -- Carlos G Mendioroz <tr...@ac...> |
From: Carlos G M. <tr...@ac...> - 2006-09-29 22:29:09
|
Stefan, I've been testing this, mainly using originateToExtensionAsync() because it's easier to tell apart what's going on. "success" is returned as soon as the first (originating) channel is instantiated. Also, using Local channels to originate is not giving any real reason for the error, I guess because the channel is lost right away. I did many test extensions like: ; Test answer and hold exten => 8506,1,Answer exten => 8506,n,Wait,300 ; Test N/A exten=> 8507,1,Ringing() exten=> 8507,n,Wait(60) ; Test congestion exten=> 8508,1,Congestion() ; Test busy exten=> 8509,1,Busy() and by calling from/to different ones it's easy to see the behaviour. I will fall back to manager API (instead of live) and see if I can understand how to do it. -Carlos Stefan Reuter @ 29/09/2006 11:58 -0300 dixit: > Carlos G Mendioroz wrote: >> Yes, and it sort of works, but I don't get access to the failure >> conditions. (i.e. Busy becomes channel unavailable) :( >> >> Hmm, I thought it was going to be an easy one ... > > no. detecting the cause for a failure is one of the most complicated > things with the originate stuff and the current implementation in > Asterisk-Java is probably far from excellent in this regard. > You can do me a favor and provide me with a detailed description of the > situations (i.e. what you did in your code and whether the caller/callee > is busy an), a dump of the events received through the Manager API (see > http://asterisk-java.org/page/aj?entry=debugging_manager_api) and the > logs. Then I can further investigate and possibly enhance the detection. > > =Stefan > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > ------------------------------------------------------------------------ > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users -- Carlos G Mendioroz <tr...@ac...> |
From: Carlos G M. <tr...@ac...> - 2006-09-30 10:39:01
|
Well, I learned a lot of Local channel behaviour. I thought it would be ok to share, let me know if this is not ok with this list. Local channel origination does indeed what I expected, but in a cool (read non-obvious to me) way. It actually creates 2 channels which work sort of pty/ttyp pair (master/slave) where the master connects to whatever extension you provide as channel id (i.e. Local/exten@context) and once the master is up, the slave does the origination. When the slave gets into an UP state, some channel renaming happens so the Local pair vanishes. For my need (automatic origination to real external number and then connect to local app) the needed steps are: 0) originate from Local/<realnumber>@<context> to <local extension> 1) locate Local session being used, it's a prefix for the two local channels, with suffix ",1" for master and ",2" for slave 2) track UniqueIDs for slave (not using it now) 3) locate "real" (remote) channel being instantiated for call 4) track remote state The piece of trick is to use a fake callerID in the originate to be able to locate the channels (mind there might be lots of calls going at once) The originate returns as soon as the master local channel is UP. In my test version (1.2.0beta) originating from Local/<realnumber>@<context> does lock the manager connection (i.e. no other events are reported untill originate succeeds or fails, so originating from a "fake" works always extension and redirecting to the app once the slave connects to the real number sounds a better thing to do. Demo code: ... originateAction = new OriginateAction(); originateAction.setChannel("Local/1000@local"); originateAction.setContext("local"); originateAction.setExten("8502"); originateAction.setPriority(new Integer(1)); originateAction.setCallerId("call1000"); originateAction.setTimeout(new Integer(15000)); // connect to Asterisk and log in managerConnection.login(); managerConnection.addEventListener(new ManagerEventListenerProxy(this)); originateResponse = managerConnection.sendAction(originateAction, 30000); ... String myCallerId = "call1000"; String myLocalChannel = null; String myRemoteChannel = null; String myUid1 = null; //Local master side String myUid2 = null; //Local slave side String myUid3 = null; //Remote public void onManagerEvent(ManagerEvent event) { if (myLocalChannel == null && event.getClass().equals(NewCallerIdEvent.class)) { if (((NewCallerIdEvent)event).getCallerIdName().equals(myCallerId)) { // #1: locate our base channel name, i.e., Local session (prefix) myLocalChannel = ((NewCallerIdEvent)event).getChannel(); if (myLocalChannel.length() > 2) myLocalChannel = myLocalChannel.substring(0, myLocalChannel.length()-2); myUid1 = ((NewCallerIdEvent)event).getUniqueId(); System.out.println("#1: " + myLocalChannel + "/" + myUid1); } } else if (myLocalChannel != null && myUid2 == null && event.getClass().equals(NewStateEvent.class)) { if (((NewStateEvent)event).getChannel().equals(myLocalChannel+",2")) { // #2: determine slave Uid myUid2 = ((NewStateEvent)event).getUniqueId(); System.out.println("#2: " + myLocalChannel + "/" + myUid2); } } else if (myLocalChannel != null && myUid3 == null && event.getClass().equals(NewChannelEvent.class)) { if (((NewChannelEvent)event).getCallerIdName().equals(myCallerId) && !((NewChannelEvent)event).getChannel().startsWith(myLocalChannel)) { // #3: locate our remote channel name myRemoteChannel = ((NewChannelEvent)event).getChannel(); myUid3 = ((NewChannelEvent)event).getUniqueId(); System.out.println("#3: " + myRemoteChannel + "/" + myUid3); System.out.println(((NewChannelEvent)event).getState()); } } else if (myUid3 != null) { if (event.getClass().equals(NewChannelEvent.class) && ((NewChannelEvent)event).getUniqueId().equals(myUid3)) { // #4: Change of state System.out.println(((NewChannelEvent)event).getState()); } else if (event.getClass().equals(NewStateEvent.class) && ((NewStateEvent)event).getUniqueId().equals(myUid3)) { // #4: Change of state System.out.println(((NewStateEvent)event).getState()); } } } Stefan Reuter @ 29/09/2006 11:58 -0300 dixit: > Carlos G Mendioroz wrote: >> Yes, and it sort of works, but I don't get access to the failure >> conditions. (i.e. Busy becomes channel unavailable) :( >> >> Hmm, I thought it was going to be an easy one ... > > no. detecting the cause for a failure is one of the most complicated > things with the originate stuff and the current implementation in > Asterisk-Java is probably far from excellent in this regard. > You can do me a favor and provide me with a detailed description of the > situations (i.e. what you did in your code and whether the caller/callee > is busy an), a dump of the events received through the Manager API (see > http://asterisk-java.org/page/aj?entry=debugging_manager_api) and the > logs. Then I can further investigate and possibly enhance the detection. > > =Stefan > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > ------------------------------------------------------------------------ > > _______________________________________________ > Asterisk-java-users mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-users -- Carlos G Mendioroz <tr...@ac...> |