20 seconds pauses

I have just installed Asterisk from scratch, Asterisk 1.8.10.0-1digium1~natty, on Ubuntu 11.04 natty.

After have made some basic configuration of sip.conf to register Asterisk as a client for my SIP provider, I found that, Asterisk is sending SIP packages with 20 seconds pauses. For example:

No. Time Source Destination Protocol Info
3 18:13:52.173448 192.168.1.200 87.xx.xx.xxx SIP Request: REGISTER sip:somedomain.com
4 18:13:52.216283 87.xx.xx.xxx 192.168.1.200 SIP Status: 401 Unauthorized (0 bindings)
5 18:14:12.189177 192.168.1.200 87.xx.xx.xxx SIP Request: REGISTER sip:somedomain.com
6 18:14:12.219504 87.xx.xx.xxx 192.168.1.200 SIP Status: 200 OK (1 bindings)

This causes the server to remove the registrastion for a while. And Asterisk is also reporting errors like:

Registration for 'account@somedomain.com’ timed out, trying again (Attempt #2)

My question:

Is there a way to make Asterisk immediately respond “401 Unauthorized” message containing nonce information?

Why Asterisk always waits such 20 seconds before sending next SIP package? Can I turn it off, how?

Thanks!

Hi Kexin,
I am new to Asterisk so forgive me if this is incorrect but in sip.conf, there is a registertimeout=20. Couldn’t you just set that to 0?

This may be a case of the blind leading the blind but I would at least start in sip.conf.

Thanks,
Shawn

Thanks Shawn. I think also that it is quite logical. So I had already tried it, among many other things in sip.conf. Unfortunately no help at all. In fact, setting registertimeout less than 20 gives more troubles. The nonce key comes back with “401 Unauthorized” message would get timeout while Asterisk is taking the 20 seconds pause.

One thing is verified: No matter how long registertimeout is set to, Asterisk is taking these 20 seconds pauses anyway.

Asterisk doesn’t have such a pause. My guess is that you have a DNS problem causing a wait for a timeout on the first choice server.

Thanks for your suggestion, David.

It might be something else forcing Asterisk to take those pauses, but it is not DNS. My installation has no problem to resolve DNS, and at the first SIP registration attempt the DNS name was already resolved. I don’t believe that Asterisk makes no cache of DNS resolutions.

I’ll try to make another fresh installation of Ubuntu and Asterisk, maybe version 1.6, just to see whether the problem still exists.

OK, David. It was because of DNS. Although not really “wait for a timeout on the first choice server”, in fact for a timeout on SRV record!

Asterisk makes absolutely NO cache of DNS resolutions! In a “register – 401 unauthorized with challenge nonce – register with credential – 200 OK” dialog, Asterisk resolves actually the same DNS name twice within 0.1 second! Stupid or what?

In my copy-paste generated sip.conf file, I happened to take “srvlookup=yes” along with many other things. Then Asterisk always tried to resolve SRV record for involved DNS names first and waited to get timeout before asking the real DNS names. This cost exactly 20 seconds in my normal DNS configuration.

After setting it to no, the whole thing works now.