Thread: Antw: [Asterisk-java-users] Problem with UniqueId and originate command
Brought to you by:
srt
From: Stefan R. <ste...@po...> - 2005-05-12 07:39:24
|
Hi Ben, what interface do you use to send the originate action? AsteriskManager or AsteriskConnection? The response to the OriginateAction is not sent until the first channel has been answered. So if the timeout Asterisk-Java uses to wait for the response is smaller than the time you need to pick up the phone, no response has yet been received and your uniqueId will be null. Please verify this by picking up the phone immediately (I think the default timeout is 3 seconds, so within at least 3 seconds after sending the OriginateAction). If this works we have to adjust the timeout to a more sensible value. Regards =Stefan |
From: Ben H. <bra...@gm...> - 2005-05-12 21:01:53
|
On 5/12/05, Stefan Reuter <ste...@po...> wrote: > Hi Ben, >=20 > what interface do you use to send the originate action? AsteriskManager o= r AsteriskConnection? I got a ManagerConnection, then created an originate action, then did: originateResponse =3D managerConnection.sendAction(originateAction, 65000); I'm not sure which that counts as... :-) >=20 > The response to the OriginateAction is not sent until the first channel h= as been answered. So if the timeout Asterisk-Java uses to wait for the resp= onse is smaller than the time you need to pick up the phone, no response ha= s yet been received and your uniqueId will be null. Is that the 2nd param to sendAction or some * config? 65000 is the actual value I used, and the phone picks up after 2 rings. >=20 > Please verify this by picking up the phone immediately (I think the defau= lt timeout is 3 seconds, so within at least 3 seconds after sending the Ori= ginateAction). > If this works we have to adjust the timeout to a more sensible value. Where can I find the 3 second setting? I should also mention that this is going out on a VoIP channel, so there is a small added delay between the originate command and the time * actually gets the channel, perhaps at most a second. Thanks! Ben |
From: Ben H. <bra...@gm...> - 2005-05-16 00:57:05
|
A little more info... I have tried several times since, and am still unable to get the UniqueId from the response. All of the events have UniqueId, but the response does not. The following is the output of dumping every event and the response on an originate from a Zap channel and answering as soon as possible: net.sf.asterisk.manager.event.NewChannelEvent: dateReceived=3DSun May 15 17= :49:03 PDT 2005; systemHashcode=3D3853415 Channel =3D Zap/1-1 State =3D Rsrvd UniqueId =3D 1116200804.74 CallerId =3D <unknown> CallerIdName =3D null DateReceived =3D Sun May 15 17:49:03 PDT 2005 Source =3D AsteriskServer[hostname=3D'10.25.25.12',port=3D5038] Class =3D class net.sf.asterisk.manager.event.NewChannelEvent net.sf.asterisk.manager.event.NewCallerIdEvent: dateReceived=3DSun May 15 1= 7:49:03 PDT 2005; systemHashcode=3D4301103 Channel =3D Zap/1-1 UniqueId =3D 1116200804.74 CallerId =3D xxxxxxxxxx CallerIdName =3D null DateReceived =3D Sun May 15 17:49:03 PDT 2005 Source =3D AsteriskServer[hostname=3D'10.25.25.12',port=3D5038] Class =3D class net.sf.asterisk.manager.event.NewCallerIdEvent net.sf.asterisk.manager.event.NewCallerIdEvent: dateReceived=3DSun May 15 1= 7:49:03 PDT 2005; systemHashcode=3D12406332 Channel =3D Zap/1-1 UniqueId =3D 1116200804.74 CallerId =3D xxxxxxxxxx CallerIdName =3D null DateReceived =3D Sun May 15 17:49:03 PDT 2005 Source =3D AsteriskServer[hostname=3D'10.25.25.12',port=3D5038] Class =3D class net.sf.asterisk.manager.event.NewCallerIdEvent net.sf.asterisk.manager.event.NewStateEvent: dateReceived=3DSun May 15 17:4= 9:03 PD T 2005; systemHashcode=3D5994703 Channel =3D Zap/1-1 State =3D Dialing UniqueId =3D 1116200804.74 CallerId =3D xxxxxxxxxx CallerIdName =3D null DateReceived =3D Sun May 15 17:49:03 PDT 2005 Source =3D AsteriskServer[hostname=3D'10.25.25.12',port=3D5038] Class =3D class net.sf.asterisk.manager.event.NewStateEvent net.sf.asterisk.manager.event.NewStateEvent: dateReceived=3DSun May 15 17:4= 9:04 PD T 2005; systemHashcode=3D22577957 Channel =3D Zap/1-1 State =3D Ringing UniqueId =3D 1116200804.74 CallerId =3D xxxxxxxxxx CallerIdName =3D null DateReceived =3D Sun May 15 17:49:04 PDT 2005 Source =3D AsteriskServer[hostname=3D'10.25.25.12',port=3D5038] Class =3D class net.sf.asterisk.manager.event.NewStateEvent net.sf.asterisk.manager.event.NewStateEvent: dateReceived=3DSun May 15 17:4= 9:06 PD T 2005; systemHashcode=3D666168 Channel =3D Zap/1-1 State =3D Up UniqueId =3D 1116200804.74 CallerId =3D xxxxxxxxxx CallerIdName =3D null DateReceived =3D Sun May 15 17:49:06 PDT 2005 Source =3D AsteriskServer[hostname=3D'10.25.25.12',port=3D5038] Class =3D class net.sf.asterisk.manager.event.NewStateEvent net.sf.asterisk.manager.event.NewExtenEvent: dateReceived=3DSun May 15 17:4= 9:06 PD T 2005; systemHashcode=3D3559661 Context =3D astagi Priority =3D 1 Channel =3D Zap/1-1 UniqueId =3D 1116200804.74 Extension =3D s Application =3D AGI AppData =3D agi://10.25.25.100/outbound.agi DateReceived =3D Sun May 15 17:49:06 PDT 2005 Source =3D AsteriskServer[hostname=3D'10.25.25.12',port=3D5038] Class =3D class net.sf.asterisk.manager.event.NewExtenEvent net.sf.asterisk.manager.response.ManagerResponse: actionId=3D'null'; messag= e=3D'Orig inate successfully queued'; response=3D'Success'; uniqueId=3D'null'; system= Hashcode=3D 22669966 Message =3D Originate successfully queued Attributes =3D {actionid=3D4059123_4#, message=3DOriginate successf= ully queued , response=3DSuccess} Response =3D Success UniqueId =3D null ActionId =3D null DateReceived =3D Sun May 15 17:49:06 PDT 2005 Class =3D class net.sf.asterisk.manager.response.ManagerResponse [snip remainder of call] The call went through just. All of the following events have the UniqueId. Is there another way to track the events to the originate?=20 Thanks again, Ben |
From: Stefan R. <sr...@re...> - 2005-05-16 23:21:55
|
Hi Ben, sorry for the late response. > There is no UniqueId in the manager response. I did some digging, and > I don't think it is in any released version of asterisk. Googling the > lists, it looks like it was added in manager.c CVS version 1.85, but > Asterisk 1.0.7 only has 1.74.2.1 Yes thats what I found too. I am using the bristuff patches from junghanns.net. These include the UniqueId for the Response to OriginateAction. What version of Asterisk are you using? 1.0.7? =3DStefan |
From: Ben H. <bra...@gm...> - 2005-05-16 23:51:05
|
I was running CVS-v1-0-04/07/05 I will get 1.0.7 and use the bristuff patches and save some time :-) Thanks for the info! - Ben On 5/16/05, Stefan Reuter <sr...@re...> wrote: > Hi Ben, >=20 > sorry for the late response. >=20 > > There is no UniqueId in the manager response. I did some digging, and > > I don't think it is in any released version of asterisk. Googling the > > lists, it looks like it was added in manager.c CVS version 1.85, but > > Asterisk 1.0.7 only has 1.74.2.1 > Yes thats what I found too. > I am using the bristuff patches from junghanns.net. These include the > UniqueId for the Response to OriginateAction. >=20 > What version of Asterisk are you using? 1.0.7? >=20 > =3DStefan >=20 >=20 > BodyID:212166270.2.n.logpart (stored separately) >=20 > |
From: Stefan R. <sr...@re...> - 2005-05-17 22:13:51
|
On Tue, 2005-05-17 at 14:54 -0700, Ben Hencke wrote: > I'm working on a method to do an originate and listen for the events. > This should be compatible with future versions of asterisk that at > least have the UniqueId in the Originate related events. > I'll post some code and interim * patches when I have it working. I hope those events include the ActionId sent with your OriginateAction. Several Actions don't send their result as a Response but use ManagerEvents instead. Another famous examples for this is the StatusAction. Leaving all these details up to the user of Asterisk-Java seems not to be the best solution.=20 So if you would like to contribute feel free to change the originateCall method in the DefaultAsteriskManager and submit your patches. =3DStefan |
From: Stefan R. <sr...@re...> - 2005-05-17 23:07:49
|
> Would it make sense to create a psudo ManagerResponse called > OriginateResponse that has all of the info? ie proposed new method: >=20 > public OriginateResponse originateCall(OriginateAction > originateAction, long timeout) throws TimeoutException, IOException the AsteriskManager interface is meant to me more abstract, so you dont have to handle the details of actions and responses. If you look at getCalls() for example thats how i think it should work. The current method String originateCall(OriginateAction originateAction) is therefore not that well designed as the signature should not depend on the OriginateAction. Returning only the uniqueId isn't sufficient either as we also need to indicate success or failure. The best way would be to design some more "domain objects" like Channel or Queue that can be translated to and from events and actions. I think of something like Call originateCall(String sourceChannel, DialPlanEntry destination) throws OriginateFailureException Call originateCall(String sourceChannel, Application destination) throws OriginateFailureException assuming Call to be a collection of linked (bridged) channels, DialPlanEntry to contain exten, contect and priority and Application to contain application and data. whats your opinion on this? =3DStefan |
From: Ben H. <bra...@gm...> - 2005-05-18 23:47:48
Attachments:
asterisk-java.diff
asterisk.diff
|
The asterisk-java.patch should work on the 0.2 snapshot dated 5/8. The asterisk.patch should work on asterisk 1.0.7 I went ahead and added 2 new objects: Call and Originate (for lack of a better name). Since there are so many parameters that are possible for an originate I just copied the relevant parts of OriginateAction instead of breaking it into several smaller objects like Channel and DialPlanEntry, etc. I think it can stand some refactoring in the future. Feel free to make modifications and/or tell me how to clean it up. Changes in the patch: 1. AsteriskManager Originate signature and it now also throws generic Exceptions to cover other possible implementations or circumstances. (ie InterruptedException when the thread waits for the Originate to finish). 2. Added event handlers for the Originate related events to DefaultAsteriskManager 3. Added a calls map to DefaultAsteriskManager to keep track of the calls that are going out by actionid. They are removed after they originate, but could be stored and used later. (maybe combined w/ channel for CDR like information) 4. Changed DefaultManagerConnection createInternalActionId to createUniqueActionId and made it part of the interface. (it was useful to create a connection specific uniqueid) 5. Added uniqueId and reason to the Originate Events (as per the asterisk implementation in CVS) With these changes, It works with the * implementation of the uniqueId tracking that is implemented in the latest CVS and the provided patch to 1.0.7. It might not work with your bristuff patched system unless bristuff also added the uniqueid and reason to the originate events. Since *-j didn't have these, I assume it is probably not in there. It should be possible with a few modifications to work with both mainstream and bristuff branches of asterisk. ie just check for uniqueid in the response and use that instead of actionid for the calls map and event handlers. There may be a small race possibility if * sends back the originate event before the sendAction call returns and the call is put in the calls collection. The Async=3Dtrue setting should make this a slim possibility but still a possibility. Any ideas? - Ben |
From: Ben H. <bra...@gm...> - 2005-05-16 23:08:52
|
I think I found the problem.=20 I recreated an originate command and sent it manually to * (using telnet). There is no UniqueId in the manager response. I did some digging, and I don't think it is in any released version of asterisk. Googling the lists, it looks like it was added in manager.c CVS version 1.85, but Asterisk 1.0.7 only has 1.74.2.1 I will try to port the changes back in to my version. - Ben |
From: Ben H. <bra...@gm...> - 2005-05-17 21:54:06
|
I tried the bristuff patches, but everything is glommed into one patch that seems to be incompatible with my sangoma card :-( I back-ported the 1.85 patch to a fresh 1.0.7, only to realize that it only affects the OriginateSuccess event or the OriginateFailure event, and does nothing for the response. This would still be somewhat useful as the OriginateSuccess/Failure events have the ActionID in it and that could be used to track the call progress and get the UniqueId. I checked out the latest manager.c (CVS 1.97) and there is still nothing for uniqueid in the response. I'm working on a method to do an originate and listen for the events. This should be compatible with future versions of asterisk that at least have the UniqueId in the Originate related events. I'll post some code and interim * patches when I have it working. Thanks again for the help and thanks for asterisk-java :-) - Ben On 5/16/05, Ben Hencke <bra...@gm...> wrote: > I was running CVS-v1-0-04/07/05 > I will get 1.0.7 and use the bristuff patches and save some time :-) > Thanks for the info! > - Ben >=20 >=20 > On 5/16/05, Stefan Reuter <sr...@re...> wrote: > > Hi Ben, > > > > sorry for the late response. > > > > > There is no UniqueId in the manager response. I did some digging, and > > > I don't think it is in any released version of asterisk. Googling the > > > lists, it looks like it was added in manager.c CVS version 1.85, but > > > Asterisk 1.0.7 only has 1.74.2.1 > > Yes thats what I found too. > > I am using the bristuff patches from junghanns.net. These include the > > UniqueId for the Response to OriginateAction. > > > > What version of Asterisk are you using? 1.0.7? > > > > =3DStefan > > > > > > BodyID:212166270.2.n.logpart (stored separately) > > > > > |
From: Ben H. <bra...@gm...> - 2005-05-17 22:46:27
|
On 5/17/05, Stefan Reuter <sr...@re...> wrote: >=20 > I hope those events include the ActionId sent with your OriginateAction. > Several Actions don't send their result as a Response but use > ManagerEvents instead. Another famous examples for this is the > StatusAction. Leaving all these details up to the user of Asterisk-Java > seems not to be the best solution. Yes, they do. The events only get posted if the Originate is Async though. >=20 > So if you would like to contribute feel free to change the originateCall > method in the DefaultAsteriskManager and submit your patches. Sure, I would be happy to contribute. Would it make sense to create a psudo ManagerResponse called OriginateResponse that has all of the info? ie proposed new method: public OriginateResponse originateCall(OriginateAction originateAction, long timeout) throws TimeoutException, IOException The originate would also have to set the action's Async setting. Let me know what you think and I'll get to work :-) - Ben |