Absolutely no reaction at incoming calls (RESOLVED)

Various kinds of problems with incoming calls seem to be a very popular issue; I’m sorry for bringing it up again, but I couldn’t find anything that would be relevant to my case.

I have a SIP account at my SIP provider, and an Asterisk server with direct Internet access to use it.

  • Outgoing calls and calls between users on that server are working fine;
  • My SIP account is “registered” (‘sip show registry’);
  • I use a softphone, and I can connect to that server from my home network behind NAT;
  • I have opened UDP port 5060 on that server, and I’ve also tried opening UDP ports 10000-20000, which didn’t help, and I believe it is unnecessary anyway, because I can connect and make calls on that server from outside with my softphone;
  • If I shut down that server and connect to my SIP provider directly with my softphone (even from a network behind NAT with no ports forwarded), incoming calls work fine, which indicates that no port forwarding is actually necessary at all and this is not a network problem;
  • However, when the Asterisk server is registered, the incoming calls return “busy” tone, and what’s most ridiculous, there is absolutely no reaction at all from Asterisk (I run ‘sudo asterisk -vvvvvr’ to see if anything is happening at all, and it doesn’t say anything). So, the call does reach my server, but Asterisk refuses to even notice it for no reason and without even any indication.

What am I doing wrong? Are there any more detailed logs to look for or something?.. I can’t believe Asterisk simply discards the call and doesn’t even say anything in the logs…

I have read the “Asterisk Book”, and tried to find an answer there several times, but according to the book, it should be very simple and it should work! Here are the relevant parts of my configs (I’ve left out some irrelevant comments and things about local endpoints calling each other). The “Verbose” thing in the incoming context does not even appear in the logs, and I’ve tried without it in case I’ve spelled it wrong.

sip.conf:

[general]
context = guest-noauth
allowguest = no ; I've tried changing this

srvlookup = yes
udpbindaddr = 0.0.0.0
tcpenable = no

disallow = all
;allow = gsm
allow = alaw
allow = ulaw

nat = comedia
canreinvite = no
directmedia = nonat
directmediadeny = 0.0.0.0/0

; === === === Provider === === ===

register => login:password@sip.myprov.ru/myprov

[myprov]
type = peer
context = incoming
host = sip.myprov.ru

username=login
secret=password
fromuser=login
fromdomain=sip.myprov.ru

; === === === Digital phones (users) === === ===

[digital](!)
type = friend
context = Digital
host = dynamic

[test](digital)
secret = mypassword

extensions.conf:

[general]
static = yes
writeprotect = no
clearglobalvars = yes

[guest-noauth]
exten => _X.,1,Answer()
 same => n,SayUnixTime()
 same => n,Hangup

[Digital]
include => outgoing

[outgoing]
exten => _8.,1,Dial(SIP/${EXTEN}@myprov,,TK)

[incoming]
exten => s,1,Verbose(2,Incoming call to ${EXTEN})
 same => n,Answer()
 same => n,Playback(hello-world)
 same => n,SayUnixTime()
 same => n,Hangup

You don’t have an extension called myprov in extensions.con. However, it should fallback to s anyway. (The /myprov on register may be a misunderstanding.)

Just to double check. Your Asterisk system is directly on the public IP address?

Are you sure that incoming calls from the provide come from the same IP address as used for outgoing ones?

Does your provider authenticate to you with the same secret as you authenticate to them? Most don’t authenticate at all, in which case you want remotesecret, rather than secret, on modern versions of Asterisk, or insecure=invite on older ones.

username is obsolete for defaultuser and is really for host=dynamic entries. canreinvite is obsolete for directmedia.

I did not know what extension do incoming calls go to - is it my external number or the name of the SIP endpoint for the provider or something else?.. I’ve found that usually people seem to be using “s” for “all calls”, so I used it; it should be failsafe. I’ve tried changing it to “myprov” (the name of my SIP endpoint), but it did not make any difference.

Yes, I have a public IP for my Asterisk system, with UDP port 5060 open in the firewall. I’m not sure if it is even necessary, because my softphone can accept incoming calls even from behind a NAT router with no ports forwarded, which probably means that all communication goes over an outgoing connection from me (softphone or Asterisk) to the provider. I have no idea how SIP or RTP works; is there a good up-to-date read about that anywhere?.. I don’t want to read the RFC since it’s usually too much too detailed information and there are probably a lot of updates in other documents…

I think it’s safe to assume the incoming calls do come from the same server. It would not make sense to have them come from another IP, as this is a simple SIP provider; and if they did that, then how would it traverse NAT with no ports forwarded?..

The weirdest thing is, there is absolutely nothing in the logs; the SIP port is open, so the connection can definitely reach Asterisk, and whatever happens next should be visible in a detailed log. But I don’t even see anything like “Incoming connection from myprov - finding out what to do with it…”; come to think about it, I’ve never seen anything like that on local calls, either! So, the question is: is it possible to have even more detailed debug logs than “asterisk -vvvvvr” ? To the point where every “debug” message is logged?..

I’ve changed “secret” to “remotesecret”. It still doesn’t work, but now I do see “Using SIP RTP CoS mark 5” line upon an incoming call! So the connection is there, and there was a problem with authenticating it, which for some reason did not give me a “WARNING - SECURITY ALERT! Unauthenticated call incoming!” log line. So if there was a way to see more detailed logs, then I would be able to determine what happens next…

By the way, I don’t even see my “Verbose” line in the logs. So the call does not even reach my dialplan.

Apparently, Verbose() not only doesn’t work, but also drops the call with no error message. If I put Verbose() into a local extension and try to dial it, it just exits with no warning, not even a debug message. Maybe I need an additional module loaded for Verbose() to work, which seems really ridiculous, and should generate an “Unknown application” error message?.. I’ve tried to load all modules (autoload=yes), and Verbose(0,Incoming call to ${EXTEN}) started working in a local call, but incoming calls still don’t reach it.

Is your logger.conf configured to send verbose messages to the console or log file, and is the verbose level set up (core set verbose 9)?

I’ve found several things I for some reason did not know. Contrary to what I’ve thought, it’s not enough to “asterisk -vvvvvr” to get the most detailed logging.

First, the maximum debug level is 10, not 5. However, running “asterisk -vvvvvvvvvvr”, which I have tried even before to make sure I have the most verbose logging level, is not enough. For some reason, you must have a logger.conf file with “console => warning,notice,error,event,debug” in the [logfiles] section. Apparently, “verbosity levels” are not the same as “error,warning,notice,debug” as it usually is. Also, you must set verbosity to 10 by either running Asterisk with “asterisk -vvvvvvvvvr”, or “core set verbose 10” (not just “set verbose 10” as the Asterisk Book says).

And “debug” is also not the same as “the most verbose level”; the “debug verbosity level” is set separately by “core set debog 10”. Both of those can be checked with “core show settings”. But I don’t seem to need “debug” - verbosity level 10 with event logging is enough, I simply thought I have the maximum level of verbosity and types of events logged already.

Doing that helped me see that for some reason, incoming calls do NOT fall through to “s” - you must actually have your provider endpoint name there. I did that, and now it works. Holy Tux, finally! I should have googled more about verbosity in Asterisk instead of just asking about it here as a side question…

Don’t forget to turn off debug and change verbosity back to 3 because your disk will fill up in no time.