How to call using an extension connected to

Apr 22, 2014 at 10:01 AM
I try doing
mConnection.SendAction(new OriginateAction()
                {
                    Channel = "SIP/201test",
                    Exten = "401",
                    Context = "201", 
                    Priority = "1",
                    CallerId = "201",
                    Timeout = 3000000
                });
Where 201 and 401 extensions are connected to my local network. I am trying to call from 201 to 401.
What am I doing wrong?
Coordinator
Apr 22, 2014 at 10:06 AM
What error are you getting? Have you looked at the output of the asterisk console?

The code you posted will call the channel "SIP/201test", when it answers, it'll connect it to the dialplan, using the context, exten and prio provided. Are they correct?

Paste the output of the asterisk console, do "core set verbose 255" to ensure you get the full output.
Apr 22, 2014 at 10:11 AM
Edited Apr 22, 2014 at 10:21 AM
Thank you for your reply.

Emmm... Now I am a bit lost... Actually what I am trying to do is following:
  1. I have a test application with a button "Call"
  2. I have 2 extensions connected to my server - 201, 401
  3. I want to call from 201 to 401 on "Call" button click
Am i going wrong direction?
I appreciate your help.

EDIT:
Channel name I selected randomly I am even not sure if I am right.

EDIT1:
"The code you posted will call the channel "SIP/201test", when it answers, it'll connect it to the dialplan, using the context, exten and prio provided. Are they correct? "
I am pretty sure they are not, could you guide me how to choose the right ones?

EDIT2:
"What error are you getting?"
I get no errors, just my code does nothing.
Apr 22, 2014 at 10:36 AM
Edited Apr 22, 2014 at 10:37 AM
UPDATE:
mConnection.SendAction(new OriginateAction()
                {
                    Channel = "SIP/401",
                    Exten = "401",
                    Context = "default",
                    Priority = "1",
                    CallerId = "201"
                    Timeout = 3000000
                });
This way 401 receives a call from 201, when answering the phone, a voice tells that 201 is on the phone, and it is followed by a beep. BUT 201 actually is not calling, as when taking the phone tube of 201, it is not connected to 401.
Coordinator
Apr 22, 2014 at 11:48 AM
You want the device you want to call to be the channel (just like you would in the dialplan "SIP/<device_name>"

You want the dialplan extension and context to be the device that device (in your case 401) to call. Which is 201.

So, assuming in your dial plan you have a context called default and an extension called 201, you would set the following: -
mConnection.SendAction(new OriginateAction()
                {
                    Channel = "SIP/401",
                    Exten = "201",
                    Context = "default",
                    Priority = "1",
                    CallerId = "401"
                    Timeout = 3000000
                });
This calls 401, waits for it to answer, and then on answer, connects 401 to extension 201 in the dial plan.
Marked as answer by megibyan on 4/22/2014 at 5:04 AM
Apr 22, 2014 at 11:59 AM
That works just perfect!!! Thank you so much :))

Don't want to seem a splinter :) but could you also guide me how to record that call? :)

I tried
system.IO.File.Create(@"...\CallRecord.wav");
               if (...\CallRecord.wav"))
               {
                   try
                   {
                       Monitor.Channel = e.Channel;
                       Monitor.File = @"...\CallRecord.wav";
                       Monitor.Format = ".wav";
                       Monitor.Mix = true;
                   }
                   catch (System.IO.IOException exeptoin)
                   {
                       MessageBox.Show(exeptoin.Message);
                   }
               }
Thank you once more!
Coordinator
Apr 22, 2014 at 12:05 PM
You don't need to create a file or anything, just use the MonitorAction class, and use mConnection.SendAction(...).

The file is recorded on your asterisk box, not the machine running AsterNET!
Apr 22, 2014 at 12:07 PM
And how am I able to access that file or create a local copy of it?
Apr 22, 2014 at 12:08 PM
Review:
Just a small question regarding to the calling.

Q: is it possible first to alarm the phone that is calling (201), only after that proceed call to 401?
Coordinator
Apr 22, 2014 at 1:37 PM
With regards to your question about alerting the fist device (401) you would need to do that from the dial plan, maybe play an audio file to them!

In terms of getting the audio file to the local machine, this is one problem still to be addressed by Asterisk itself. I suggest you either use some sort of shared storage or allow for the storage on your asterisk box to be accessed remotely, maybe via SMB Shares or NFS?
Apr 22, 2014 at 1:49 PM
Thank you very much for your answers.
Regarding to the shared storage, it is a bit complicated to do it now, but I will try to manage it in future.
Thanks and regards,
Jan 10 at 8:44 PM
skrusty wrote:
You want the device you want to call to be the channel (just like you would in the dialplan "SIP/<device_name>"

You want the dialplan extension and context to be the device that device (in your case 401) to call. Which is 201.

So, assuming in your dial plan you have a context called default and an extension called 201, you would set the following: -
mConnection.SendAction(new OriginateAction()
                {
                    Channel = "SIP/401",
                    Exten = "201",
                    Context = "default",
                    Priority = "1",
                    CallerId = "401"
                    Timeout = 3000000
                });
This calls 401, waits for it to answer, and then on answer, connects 401 to extension 201 in the dial plan.
I know this is an old thread, but I need some help...
I'm coding in VB.NET, the code works (a little different):
        Dim test As New Action.OriginateAction
        test.Channel = "SIP/3000"
        test.Exten = "2035"
        test.Context = "default"
        test.Priority = "1"
        test.CallerId = "3000"
        test.Timeout = 3000000
        conn.SendAction(test)
Exten 3000 gets a call, when answering, 3000 calls 2035
But when 3000 doesn't answer in the "timeout" time, I get a TimeoutException was unhandled error:

Image

(I'm not getting this error when Exten 3000 is set to "auto answer"
Any idea?
Thanks