[asterisk-users] How to check a number online or offline
Phuong Hoang
ducphuongbk200586 at gmail.com
Tue Jan 11 04:11:11 CST 2011
Hi Dhaval,
I fired originate action on AMI and everything is ok but redirect action not
ok.
here the channel i set is available and context also exists on file
extension.conf .
I will send manager.conf,extensions.conf and sip.conf (in Extension.rar) to
you.
I registered a sip phone with account *0976468586 *and context "*TestAMQ*"
on asterisk =>ok
When i call with extension of "*TestAMQ*"(*this case extension is 999* ) by
sip phone account* 0976468586* and simultaneously run above java program
(AMI) that i sent to you to redirect the number *0976468586* to context *
"from-smg"* then received the error.
Do you use yahoo or skype?if you do, can you let me know *your ID yahoo or
skype* to say something easier. My Yahoo ID is : *
ducphuongbk200586 at yahoo.com*
Thanks and best regard
Phuong
On Tue, Jan 11, 2011 at 2:05 AM, Phuong Hoang
<ducphuongbk200586 at gmail.com>wrote:
>
>
>> On Tue, Jan 11, 2011 at 1:18 AM, DHAVAL INDRODIYA <
>> dhaval.it01034 at gmail.com> wrote:
>>
>>> Hi Phuong,
>>>
>>> i see your code is looking nice and there is no problem in implementation
>>> , if you have any problem
>>> then first send me manager.conf file then try to connect through manager
>>> using telnet and then fire same action on this in that you can get proper
>>> error codes .
>>>
>>> one more thing the channel you set is this channel is available to
>>> redirected???
>>>
>>> regards
>>> Dhavak
>>>
>>> On Tue, Jan 11, 2011 at 2:05 PM, Phuong Hoang <
>>> ducphuongbk200586 at gmail.com> wrote:
>>>
>>>> Hi Dhaval,
>>>> Can you say how to fire action on AMI in this case and recieve response
>>>> on AMI. I also tried to do with HangupAction and RedirectAction action
>>>> (using asterisk-java library) in application java (AMI) to hang up or
>>>> redirect a channel that is online at the extension on asterisk but not
>>>> successfully. This is my code:
>>>>
>>>>
>>>>
>>>> package Test;
>>>>
>>>> import java.io.IOException;
>>>>
>>>> import org.asteriskjava.manager.AuthenticationFailedException;
>>>> import org.asteriskjava.manager.ManagerConnection;
>>>> import org.asteriskjava.manager.ManagerConnectionFactory;
>>>> import org.asteriskjava.manager.TimeoutException;
>>>> import org.asteriskjava.manager.action.HangupAction;
>>>> import org.asteriskjava.manager.action.OriginateAction;
>>>> import org.asteriskjava.manager.action.RedirectAction;
>>>> import org.asteriskjava.manager.response.ManagerResponse;
>>>>
>>>> public class TestOriginate {
>>>>
>>>> /**
>>>> * @param args
>>>> */
>>>> private ManagerConnection managerConnection;
>>>>
>>>> public TestOriginate() throws IOException {
>>>> ManagerConnectionFactory factory = new ManagerConnectionFactory(
>>>> "192.168.0.178", "manager", "pa55w0rd");
>>>>
>>>> this.managerConnection = factory.createManagerConnection();
>>>>
>>>> }
>>>> public void run() {
>>>> RedirectAction redirectAction;
>>>> ManagerResponse originateResponse;
>>>> String state = "";
>>>> String receiver = "0976468586";
>>>> redirectAction = new RedirectAction();
>>>> redirectAction.setContext("from-smg");
>>>> redirectAction.setExten("9220");
>>>> redirectAction.setPriority(new Integer(1));
>>>> redirectAction.setChannel("SIP/"+ receiver);
>>>>
>>>> try {
>>>> System.out.println("Starting login 192.168.0.178");
>>>> managerConnection.login();
>>>>
>>>> System.out.println("After login 192.168.0.178");
>>>>
>>>> } catch (IllegalStateException e) {
>>>>
>>>> } catch (TimeoutException e) {
>>>>
>>>> } catch (IOException e) {
>>>>
>>>> } catch (AuthenticationFailedException e) {
>>>>
>>>> }
>>>> try {
>>>> originateResponse =
>>>> managerConnection.sendAction(redirectAction,
>>>> 30000);
>>>> state = originateResponse.getResponse();
>>>> System.out.println("State value is :" + state);
>>>> } catch (IllegalArgumentException e) {
>>>> // TODO Auto-generated catch block
>>>> e.printStackTrace();
>>>> } catch (IllegalStateException e) {
>>>> // TODO Auto-generated catch block
>>>> e.printStackTrace();
>>>> } catch (IOException e) {
>>>> // TODO Auto-generated catch block
>>>> e.printStackTrace();
>>>> } catch (TimeoutException e) {
>>>> // TODO Auto-generated catch block
>>>> e.printStackTrace();
>>>> }
>>>>
>>>> managerConnection.logoff();
>>>> }
>>>>
>>>> public static void main(String[] args) throws IOException {
>>>> // TODO Auto-generated method stub
>>>>
>>>> TestOriginate test = new TestOriginate();
>>>> test.run();
>>>> }
>>>>
>>>> }
>>>>
>>>> *While i run above code, the result printed on console likes following:
>>>> *
>>>>
>>>>
>>>> Starting login 192.168.0.178
>>>> Jan 11, 2011 3:26:01 PM
>>>> org.asteriskjava.manager.internal.ManagerConnectionImpl connect
>>>> INFO: Connecting to 192.168.0.178:5038
>>>> Jan 11, 2011 3:26:02 PM
>>>> org.asteriskjava.manager.internal.ManagerConnectionImpl
>>>> setProtocolIdentifier
>>>> INFO: Connected via Asterisk Call Manager/1.1
>>>> Jan 11, 2011 3:26:02 PM
>>>> org.asteriskjava.manager.internal.ManagerConnectionImpl
>>>> setProtocolIdentifier
>>>> WARNING: Unsupported protocol version 'Asterisk Call Manager/1.1'. Use
>>>> at your own risk.
>>>> Jan 11, 2011 3:26:02 PM
>>>> org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin
>>>> INFO: Successfully logged in
>>>> Jan 11, 2011 3:26:04 PM
>>>> org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin
>>>> INFO: Determined Asterisk version: Asterisk 1.0
>>>> After login 192.168.0.178
>>>> State value is :Error
>>>> Jan 11, 2011 3:26:04 PM
>>>> org.asteriskjava.manager.internal.ManagerConnectionImpl disconnect
>>>> INFO: Closing socket.
>>>> Jan 11, 2011 3:26:04 PM
>>>> org.asteriskjava.manager.internal.ManagerReaderImpl run
>>>> INFO: Terminating reader thread: socket closed
>>>>
>>>> I hope you can spend your time to read what i have written above and
>>>> help me solve this problem.
>>>>
>>>> Can you contact with me by my yahoo nick : ducphuongbk200586 at yahoo.com
>>>>
>>>> Thanks and best regards.
>>>> Phuong
>>>>
>>>> On Mon, Jan 10, 2011 at 10:48 PM, DHAVAL INDRODIYA <
>>>> dhaval.it01034 at gmail.com> wrote:
>>>>
>>>>> HI Phuong,
>>>>>
>>>>> JIM is right way but if you want to use extension state then there is a
>>>>> simple way of achiving through
>>>>> AMI, you need to fire this action on AMI and response have your answer
>>>>> ,
>>>>>
>>>>> Please read about Action ExtensionState.
>>>>>
>>>>>
>>>>> http://www.voip-info.org/wiki/view/Asterisk+Manager+API+Action+ExtensionState
>>>>>
>>>>> If you are looking for extension state just pass extension and you will
>>>>> receive perfect response of that extension then you cans code as you want.
>>>>>
>>>>> regards
>>>>> Dhaval
>>>>>
>>>>>
>>>>> On Tue, Jan 11, 2011 at 9:56 AM, Phuong Hoang <
>>>>> ducphuongbk200586 at gmail.com> wrote:
>>>>>
>>>>>> Hi Jim,
>>>>>> Really, I have`nt understood what you said yet. I am building a system
>>>>>> on asterisk, and want to check a number online, offline or unreachable. If
>>>>>> number is online on the extension then i want to redirect other extension.
>>>>>> Redirecting is done by application java using AMI. can you help me do it?
>>>>>> Thanks and best regards!
>>>>>> Phuong
>>>>>>
>>>>>>
>>>>>> On Mon, Jan 10, 2011 at 7:09 PM, Jim Dickenson <dickenson at cfmc.com>wrote:
>>>>>>
>>>>>>> If you do an AMI packet like this:
>>>>>>>
>>>>>>> Action: Originate
>>>>>>> Channel: Local/get_info at some_context
>>>>>>> Exten: do_noop
>>>>>>> Context: some_context
>>>>>>> Priority: 1
>>>>>>> ActionID: GetInfo
>>>>>>> Async: true
>>>>>>>
>>>>>>> and then have a couple extensions that do what you want. Here is what
>>>>>>> I do in my case:
>>>>>>>
>>>>>>> exten => get_info,1,Answer()
>>>>>>> exten => get_info,n,UserEvent(GetInfo,Version:ABE &
>>>>>>> DateTime:${STRFTIME(${EPOCH},,%Y%m%d%H%M%S)} & CfMC:83351)
>>>>>>> exten => get_info,n,Hangup()
>>>>>>>
>>>>>>> exten => do_noop,1,Answer()
>>>>>>> exten => do_noop,n,Wait(1)
>>>>>>> exten => do_noop,n,Hangup()
>>>>>>>
>>>>>>> You would then do what you need to do in your extensions.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Jim Dickenson
>>>>>>> mailto:dickenson at cfmc.com <dickenson at cfmc.com>
>>>>>>>
>>>>>>> CfMC
>>>>>>> http://www.cfmc.com/
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Jan 10, 2011, at 6:16 PM, Phuong Hoang wrote:
>>>>>>>
>>>>>>> Thanks Jim,
>>>>>>> Can you say about your idea clearlier? I want to use AMI in an
>>>>>>> application java to check a number online, offline or unreachable and result
>>>>>>> is returned to the appliction java. If the number is online now, i will use
>>>>>>> AMI to hangup it, else i do nothing.
>>>>>>> Best regards,
>>>>>>> Phuong.
>>>>>>>
>>>>>>> On Mon, Jan 10, 2011 at 8:50 AM, Jim Dickenson <dickenson at cfmc.com>wrote:
>>>>>>>
>>>>>>>> You can always place a "call" to an extension that sends a user
>>>>>>>> event from AMI. If there are no native AMI commands that can return what you
>>>>>>>> want originate a call to a local extension that returns a user event.
>>>>>>>> --
>>>>>>>> Jim Dickenson
>>>>>>>> mailto:dickenson at cfmc.com <dickenson at cfmc.com>
>>>>>>>>
>>>>>>>> CfMC
>>>>>>>> http://www.cfmc.com/
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Jan 10, 2011, at 7:48 AM, Phuong Hoang wrote:
>>>>>>>>
>>>>>>>> Thanks Dhaval,
>>>>>>>> My purpose is that i want to use java application (using Asterisk
>>>>>>>> Manager Interface) to check a number online, offline or unreachable. Your
>>>>>>>> suggest uses function DEVICE_STATE but this is written in dialplan not
>>>>>>>> application java. Do you know other way to do this for me?thanks and looks
>>>>>>>> forward to listening your reply.
>>>>>>>> Regards!
>>>>>>>> Phuong
>>>>>>>>
>>>>>>>> On Mon, Jan 10, 2011 at 3:13 AM, DHAVAL INDRODIYA <
>>>>>>>> dhaval.it01034 at gmail.com> wrote:
>>>>>>>>
>>>>>>>>>
>>>>>>>>> Hello ,
>>>>>>>>>
>>>>>>>>> You can use Dialplan function DEVICE_STATE, which will gives you
>>>>>>>>> perfect status of DEVICE.
>>>>>>>>>
>>>>>>>>> regards
>>>>>>>>> Dhaval
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Jan 10, 2011 at 4:11 PM, Steve Howes <
>>>>>>>>> steve-lists at geekinter.net> wrote:
>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On 10 Jan 2011, at 10:37, Phuong Hoang wrote:
>>>>>>>>>> I found the link you have just sent to me but it do`nt help me to
>>>>>>>>>> resolve this. Can you say clearlier for me?
>>>>>>>>>>
>>>>>>>>>> Not really. It's a list of manager commands. There is
>>>>>>>>>> 'SIPshowpeer' which will work for sip stuff. Try the command 'Command'
>>>>>>>>>> action and you can send any CLI command, like sip/iax2 show peers etc.
>>>>>>>>>> 'ExtensionState' might work in some cases..
>>>>>>>>>>
>>>>>>>>>> S
>>>>>>>>>> --
>>>>>>>>>>
>>>>>>>>>> _____________________________________________________________________
>>>>>>>>>> -- Bandwidth and Colocation Provided by
>>>>>>>>>> http://www.api-digital.com --
>>>>>>>>>> New to Asterisk? Join us for a live introductory webinar every
>>>>>>>>>> Thurs:
>>>>>>>>>> http://www.asterisk.org/hello
>>>>>>>>>>
>>>>>>>>>> asterisk-users mailing list
>>>>>>>>>> To UNSUBSCRIBE or update options visit:
>>>>>>>>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> _____________________________________________________________________
>>>>>>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com--
>>>>>>>>> New to Asterisk? Join us for a live introductory webinar every
>>>>>>>>> Thurs:
>>>>>>>>> http://www.asterisk.org/hello
>>>>>>>>>
>>>>>>>>> asterisk-users mailing list
>>>>>>>>> To UNSUBSCRIBE or update options visit:
>>>>>>>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> _____________________________________________________________________
>>>>>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com--
>>>>>>>> New to Asterisk? Join us for a live introductory webinar every
>>>>>>>> Thurs:
>>>>>>>> http://www.asterisk.org/hello
>>>>>>>>
>>>>>>>> asterisk-users mailing list
>>>>>>>> To UNSUBSCRIBE or update options visit:
>>>>>>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>> _____________________________________________________________________
>>>>>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com--
>>>>>>>> New to Asterisk? Join us for a live introductory webinar every
>>>>>>>> Thurs:
>>>>>>>> http://www.asterisk.org/hello
>>>>>>>>
>>>>>>>> asterisk-users mailing list
>>>>>>>> To UNSUBSCRIBE or update options visit:
>>>>>>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> _____________________________________________________________________
>>>>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com--
>>>>>>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>>>>>> http://www.asterisk.org/hello
>>>>>>>
>>>>>>> asterisk-users mailing list
>>>>>>> To UNSUBSCRIBE or update options visit:
>>>>>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> _____________________________________________________________________
>>>>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com--
>>>>>>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>>>>>> http://www.asterisk.org/hello
>>>>>>>
>>>>>>> asterisk-users mailing list
>>>>>>> To UNSUBSCRIBE or update options visit:
>>>>>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> _____________________________________________________________________
>>>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>>>>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>>>>> http://www.asterisk.org/hello
>>>>>>
>>>>>> asterisk-users mailing list
>>>>>> To UNSUBSCRIBE or update options visit:
>>>>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> _____________________________________________________________________
>>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>>>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>>>> http://www.asterisk.org/hello
>>>>>
>>>>> asterisk-users mailing list
>>>>> To UNSUBSCRIBE or update options visit:
>>>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>>
>>>>
>>>>
>>>> --
>>>> _____________________________________________________________________
>>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>>> http://www.asterisk.org/hello
>>>>
>>>> asterisk-users mailing list
>>>> To UNSUBSCRIBE or update options visit:
>>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>>
>>>
>>>
>>> --
>>> _____________________________________________________________________
>>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>> http://www.asterisk.org/hello
>>>
>>> asterisk-users mailing list
>>> To UNSUBSCRIBE or update options visit:
>>> http://lists.digium.com/mailman/listinfo/asterisk-users
>>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110111/306f1ce7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Extension.rar
Type: application/rar
Size: 1204 bytes
Desc: not available
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20110111/306f1ce7/attachment.rar>
More information about the asterisk-users
mailing list