Inbound call on pjsip trunk rejected because extension not found in context 'from-sip-external'

We have configured a Bulgarian trunk for inbound calls for Bulgarian residents. This was first set up several years ago. Sometime in the last 8-12 months it stopped working. Part of the reason it has gone this long is we have few Bulgarian callers, and also it seemed to start working by itself a few times. But lately it never works. We reviewed everything with the trunk provider (Avoxi), tried different tests, to no avail.

We are consistently getting this error, the only variation being alternating between 2 Avoxi addresses. No one at Avoxi knows what is causing this rejection or how to resolve it. Neither does any online documentation or forum search bring me any light.

res_pjsip_session.c: anonymous: Call (TCP:104.196.177.56:5060) to extension '+35932571240' rejected because extension not found in context 'from-sip-external'.

This is the general pjsip settings. No, authentication is not required, and, yes, I have tried using dummy auth credentials, with no change in behaviour.

Let me know what else I can say/show to clarify our problem.

Thanks a lot.

The trunk isn’t being recognized. That probably means that trunk-production-us1.avoxi.com doesn’t resolve to any address that corresponds to the one from which the request is actually coming. You need to set Match/Permit to include all the address ranges from which the provider can send to you.

It might also be a SIP ALG (application level gateway) in the router, meaning call appears to come from the router. These should be disabled.

Thanks for your reply. The 2 addresses that the requests come from are both in Match/Permit. They are in the format of 104.196.177.203/32, 104.196.177.56/32

At the Asterisk command prompt, type
pjsip set logger on
make a test call (from an outside number such as your mobile) to one of the BG numbers, paste the Asterisk log for the call at pastebin.com and post the link here.

Here it is. That was fairly difficult to extract. :slight_smile: Maybe because we have some extensions re-registering at too frequent intervals.

anonymous:

It’s definitely failing to match the call against the trunk.

I’d look at the generated .conf files, and see if there is a type=identify for the address.

2 Likes

Hello,
Can you check if your trunk is registered in Report => Asterisk Info => Registries => PJSIP
If ok it should look like : trunk_provider/sip:hostname:PORT Provider_name Registered (exp. XXXs)
where trunk_provider is the name of your trunk provider, hostname the name of the server, PORT the port for the SIP server and XXX the time in s since last connection
If yes, you could try to do a broad outbound route to be sure to accept any call like :

in my case I use +41 because I am in Switzerland, you should use the correct number for your country, or the country for which it should work.

I see this in pjsip.identify.conf.

[AvoxiBG]
type=identify
endpoint=AvoxiBG
match=104.196.177.203/32, 104.196.177.56/32

As you can see in the configuration screenshot, Avoxi does not look for registration.

So it is not normal ?
Should it be registered ?

Correct, as you can see in the Avoxi configuration guide.

Have you tried to set a wild card inbound route for the dial pattern, like that you could test if it is the dial pattern that is the problem, also have you added informations like the header,
(in the trunk => PJSIP Settings => Advanced)
Contact User : +4127xxxyy00 (your phone number)
From Domain : swisscom.ch (same as server domain name)
From User : +4127xxxyy00 (your phone number)
For those settings :

check what you need to do depending of your sip provider

I don’t understand why it is being treated as anonymous, but I’d suggest making sure that anonymous is disabled, or explaining why you need it.

Is it because there is no registration?

How do I disable anonymous?

Probably under PJSIP settings, under SIP settings, but the user guide seems to be incomplete.

Right, I found that option, and it doesn’t change this rejection error, whether set to yes or no. I remember now that we’ve tried this already too.

I used ChatGPT to try to understand why from-sip-external is a problem. It recommended adding a rule for this phone number to the from-sip-eternal context. In the process, I discovered that Asterisk uses this context for anonymous calls, with the default action being reject.

Here’s the rule I added to extensions_custom.conf. Incoming calls on this trunk work now.

[from-sip-external]
exten => +35932571240,1,Goto(from-pstn,${EXTEN},1)

Yes. That’s the basis on which I’ve been working, but the problem I’m trying to solve is why it is it being considered anonymous, rather than given that it is, how to you get it back into the normal processing route.

Derek,

I am a representative from AVOXI and would like to work with you on this issue. I will reach out to your directly.

Thanks,
Greg

I just figured out that all calls on all trunks, even registered ones, are being called anonymous. We must have a misconfiguration somewhere.

It almost sounds like match by IP has been disabled.

Is this a standard installation, or have modules been loaded individually?