So you have your Asterisk PBX system all set up, and things look like they're configured exactly as they're meant to be, but for some reason incoming calls keep being rejected. When you run Asterisk in verbose mode (type sudo asterisk -r from a shell prompt on the server to enter the CLI, and then "core set verbose 999" at the command line), you see this message whenever there's an incoming call:
handle_request_invite: Call from '' to extension 's' rejected because extension not found
Now, at this point, obviously, you should make sure that your sip.conf entry for the peer that you're receiving calls from has a "context" set to one in extensions.conf that has an entry for s, eg:
register => 7726780680:1234@mysipprovider
[mysipprovider-in]
type=peer
qualify=yes
insecure=port,invite
disallow=all
allow=ulaw
context=incoming
[mysipprovider]
type=peer
secret=1234
username=7726780680
fromuser=7726780680
fromdomain=sip.example.com
host=sip.example.com
outboundproxy=sip.example.com
nat=yes
context=incoming
caninvite=no ; Appears to be required for outgoing audio
canreinvite=no ; Appears to be required for outgoing audio
disallow=all
allow=ulaw,alaw
And in extensions.conf:
[incoming]
exten => s,1,NoOp(Call from MySipProvider)
exten => s,n,Dial(SIP/exampleext&SIP/anotherexten&SIP/yetanotherone, 20)
Now, I see you reading this going "I did all this! Why is it not working!? It all looks right, and I added 's' to everything else, and it STILL doesn't work!"
Welcome to my world yesterday. Well, here's what's probably going on. Somewhere in your sip.conf you probably have something like:
domain=blahblah.mydomain.com
allowexternaldomains=no
(the latter line might even be commented out, as it's the default)
And that's fine, that's what you're supposed to do. Except... well, what seems to happen with some setups is that the messages from your SIP provider do not come with blahblah.mydomain.com (or something anonymous), they come for sip:s@<some IP address> (where <some IP address> is unrelated to anything on your network.
When that happens, you get the above error message. It doesn't mean that the configured context doesn't have 's' in it, it means that s@<some IP address> is the extension it can't find, because as far as it's concerned, the <some IP address> thing has nothing to do with it.
What are your fixes? Well, there are two possibilities.
The first - and probably preferable option - is you can use the SIP debugging tool built into Asterisk to work out who the messages are addressed to. Simply type "sip set debug" at the Asterisk CLI, and call yourself from a cellphone. You'll get a massive dump of messages like this:
INVITE sip:s@192.168.1.5:6080 SIP/2.0
Record-Route: ...
Record-Route: ...
Via: ...
Via: ..
branch=...
Via: ...
f: "PAUL - Cell" <sip:7725550168@192.168.2.3>;...
t: <sip:+17726780680@...>
{etc}
When you're done, type "sip set debug off", and make sure you're using a terminal that has a very large scroll back buffer!
Anyway, take a look at the INVITE message. What Asterisk is looking for is "INVITE <something>@blahblah.mydomain.com", and s@192.168.1.5 is not an example of that, so as far as it's concerned it's not a valid extension and it rejects it.
Solution - add "domain 192.168.1.5" to your sip.conf.
If that doesn't work, option (b) - which is less nice - is to put in
allowexternaldomains=yes
Despite the name, that line does not mean "allow anyone to route their calls through you", it means "Just ignore the domain, treat everything as local".
More recent versions of Asterisk apparently have this switched on, but not the LTS 1.4 release.
I hope this helps someone out there.
Thank you, this was the only helpful advice I found on the entire internet regarding this exact problem.
ReplyDeleteExactly, this is the right answer for unclear problem
ReplyDeleteThanks a lot Man...............
ReplyDeleteThank you! It helped 6 years later))
ReplyDelete