AsterNet.ARI external calls

Hi there,

So I had implemented come code in C# (using AsterNet.ARI) to initiate a call internally and it worked.

Now that I am trying it on live, I need to call external numbers and it is failing (by hanging up on its own).

Here is my code:

var channel =
                    Client.Channels.Originate(endpoint: $"pjsip/{callFrom}", extension: callTo, callerId: callFrom);

Any idea what I can be doing wrong?

You haven’t shown what is actually happening. Is the ARI application actually making the request to Asterisk? Does the endpoint you are calling exist? Is there any console output? Is the SIP request sent and if so what is the log for it (pjsip set logger on)?

You need to break down the scenario and isolate where it is different and failing.

I will get back to you as soon as I get access to the logs.


Hi @jcolp,

Ok so here are the logs… It seems like the request is being made. The endpoint (which i altered intentionally for this post) is my personal number which is an external number.

It first calls the extension, I picked up, and it attempts to call my personal number. Instead it just hangs up. I am guessing I am missing a parameter?

[2018-09-06 08:58:45] VERBOSE[30142] dial.c: Called 1776
[2018-09-06 08:58:45] VERBOSE[30142] dial.c: PJSIP/1776-000184a2 is ringing
[2018-09-06 08:58:46] WARNING[53130] res_pjsip_pubsub.c: No registered subscribe handler for event presence.winfo
[2018-09-06 08:58:46] WARNING[54125] res_pjsip_pubsub.c: No registered publish handler for event presence
[2018-09-06 08:58:47] VERBOSE[30142] dial.c: PJSIP/1776-000184a2 answered
[2018-09-06 08:58:47] WARNING[30142][C-0000b835] pbx.c: Channel ‘PJSIP/1776-000184a2’ sent to invalid extension but no invalid handler: context,exten,priority=outbound-context,66880038,1

The reason is stated in the last warning message. You told it to go to extension “66880038” priority 1 of context “outbound-context” when it was answered but no extension exists for that.

But I am trying to call an external number not an extension. I know I put the callto in the extension but thats because I cant find anywhere else to put the number.

The Originate route places a call to an endpoint (the PJSIP target in your case) and then once answered sends it to a location in the dialplan or an ARI application. You are telling it to do dial your PJSIP target and then go into the dialplan at that incorrect location. The endpoint value should be what you want to dial, and then the other wherever you want it to go once answered.

Ok so what I understand from your post is that I should switch the from and to like the following:

Client.Channels.Originate(endpoint: $“pjsip/{callFrom}”, extension: callTo, callerId: callFrom);

But I still get the same issue… this time without logs.

Those are variables, I have no idea of their contents so can’t say whether they are correct or not. For example if “callFrom” contains a dialplan location then you can’t dial that using a PJSIP channel, you have to dial it using a Local channel.

Fair enough…

So first of all, I meant:

Client.Channels.Originate(endpoint: $“pjsip/{callFrom}”, extension: callTo, callerId: callFrom);

Secondly, with the values it is as follows:

Client.Channels.Originate(endpoint: $“pjsip/1776”, extension: 66880038, callerId: 1776);

Should I have a dial-phone location?

I don’t know what a “dial-phone location” is. The given originate would call pjsip/1776 and once answered send it to extension 66880038 in the dialplan.

This is the same behavior as the AMI originate, which tons of people use. You may want to search, research, experiment, and understand further in that area to get a better grasp of it all.

ugh I am sorry. I meant Dial-plan location and the variables will be as follows:

Client.Channels.Originate(endpoint: $“pjsip/66880038”, extension: “1776” , callerId: 1776);

My bad!

Those values only have context within your system, so I have no idea if those do what you want or not. You have to determine what is correct for your usage based on how I’ve said it works.

Sorry to come just now again… So this is as far as I got:

Client.Channels.Originate(endpoint: $“pjsip/66880038@GO_SIP”, extension: “1776” , callerId: “1776”);

I had to add the dial plan at the end but now we are getting:
[2018-09-07 08:16:26] WARNING[9758]: res_pjsip_outbound_authenticator_digest.c:190 digest_create_request_with_auth: Endpoint: ‘GO_SIP’: Authentication credentials not accepted by server.

Any idea why?

According to the message, the authentication credentials were not accepted by the server. You’d need to see if you are using the correct endpoint, the correct authentication credentials, that the endpoint is configured properly, and if it works in some other way - to compare the difference.

Hmm where exactly would I put the credentials? I don’t see “Client.Channels.Originate” accepting any credentials.

The only credentials I see (and make use of) are the AsterNET.ARI.StasisEndpoint which I believe is for accessing the API if i am not mistaken?

ARI has nothing to do with SIP credentials and PJSIP does not allow specifying them in the dial string. They are configured in pjsip.conf or in a realtime database if you are using that. Examples of PJSIP configuration are on the wiki[1].


Thanks. I will get back to you on this.

Ok here I am still struggling but at least I got somewhere.

I managed to call.

The issue was that the CallerId should have been the full number, not just the extension:

var channel =
		endpoint: @"PJSIP/66880038@GO_SIP",
		extension: "1776", 
		callerId: "12345776");

Now only 1 issue remains. As it is, it currently calls 66880038 first. Instead I want it to call the extension first.

Anyway to reverse this? Switching the values give a bad request.


You reverse them, but the exact values depend on the environment and configuration.