AsterNet.ARI external calls


#1

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?


#2

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.


#3

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

Thanks


#4

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


#5

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.


#6

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.


#7

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.


#8

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.


#9

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.


#10

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?


#11

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.


#12

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!


#13

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.


#14

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?


#15

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.


#16

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?


#17

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].

[1] https://wiki.asterisk.org/wiki/display/AST/res_pjsip+Configuration+Examples


#18

Thanks. I will get back to you on this.