Asterisk retransmitting REGISTER even after 200 response


#1

I have Asterisk 1.8.7.1 running on a Gentoo VPS with a static IP and am having problems registering to Broadvoice.

It looks like Asterisk is resending REGISTER requests even after getting a 200 response from Broadvoice.

Here’s the SIP debug trace:

[code]<------------->
asteriskbox*CLI> sip show registry
Host dnsmgr Username Refresh State Reg.Time
yahyabroadvoice:5060 N 4251231234@s 24 Registered Tue, 15 Nov 2011 10:29:28
1 SIP registrations.
[Nov 15 10:29:52] NOTICE[2426]: chan_sip.c:12600 sip_reregister: – Re-registration for 4251231234@yahyabroadvoice
REGISTER 11 headers, 0 lines
Reliably Transmitting (no NAT) to 147.135.20.221:5060:
REGISTER sip:sip.broadvoice.com SIP/2.0
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Max-Forwards: 70
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
User-Agent: Asterisk PBX 1.8.7.1
Authorization: Digest username=“4251231234”, realm=“BroadWorks”, algorithm=MD5, uri=“sip:sip.broadvoice.com”, nonce=“BroadWorksXgux6zemmTcc0sniBW”, response=“75b0680729b173a3a226752221cd92bf”, qop=auth, cnonce=“4359ff24”, nc=00001aca
Expires: 1800
Contact: sip:4251231234@209.177.14.14:5060
Content-Length: 0


<— SIP read from UDP:147.135.20.221:5060 —>
SIP/2.0 200 OK
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Contact: sip:4251231234@209.177.14.14:5060
Expires: 30
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Retransmitting #1 (no NAT) to 147.135.20.221:5060:
REGISTER sip:sip.broadvoice.com SIP/2.0
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Max-Forwards: 70
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
User-Agent: Asterisk PBX 1.8.7.1
Authorization: Digest username=“4251231234”, realm=“BroadWorks”, algorithm=MD5, uri=“sip:sip.broadvoice.com”, nonce=“BroadWorksXgux6zemmTcc0sniBW”, response=“75b0680729b173a3a226752221cd92bf”, qop=auth, cnonce=“4359ff24”, nc=00001aca
Expires: 1800
Contact: sip:4251231234@209.177.14.14:5060
Content-Length: 0


<— SIP read from UDP:147.135.20.221:5060 —>
SIP/2.0 200 OK
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Contact: sip:4251231234@209.177.14.14:5060
Expires: 30
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Retransmitting #2 (no NAT) to 147.135.20.221:5060:
REGISTER sip:sip.broadvoice.com SIP/2.0
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Max-Forwards: 70
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
User-Agent: Asterisk PBX 1.8.7.1
Authorization: Digest username=“4251231234”, realm=“BroadWorks”, algorithm=MD5, uri=“sip:sip.broadvoice.com”, nonce=“BroadWorksXgux6zemmTcc0sniBW”, response=“75b0680729b173a3a226752221cd92bf”, qop=auth, cnonce=“4359ff24”, nc=00001aca
Expires: 1800
Contact: sip:4251231234@209.177.14.14:5060
Content-Length: 0


<— SIP read from UDP:147.135.20.221:5060 —>
SIP/2.0 200 OK
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Contact: sip:4251231234@209.177.14.14:5060
Expires: 30
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Retransmitting #3 (no NAT) to 147.135.20.221:5060:
REGISTER sip:sip.broadvoice.com SIP/2.0
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Max-Forwards: 70
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
User-Agent: Asterisk PBX 1.8.7.1
Authorization: Digest username=“4251231234”, realm=“BroadWorks”, algorithm=MD5, uri=“sip:sip.broadvoice.com”, nonce=“BroadWorksXgux6zemmTcc0sniBW”, response=“75b0680729b173a3a226752221cd92bf”, qop=auth, cnonce=“4359ff24”, nc=00001aca
Expires: 1800
Contact: sip:4251231234@209.177.14.14:5060
Content-Length: 0


<— SIP read from UDP:147.135.20.221:5060 —>
SIP/2.0 200 OK
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Contact: sip:4251231234@209.177.14.14:5060
Expires: 30
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Retransmitting #4 (no NAT) to 147.135.20.221:5060:
REGISTER sip:sip.broadvoice.com SIP/2.0
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Max-Forwards: 70
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
User-Agent: Asterisk PBX 1.8.7.1
Authorization: Digest username=“4251231234”, realm=“BroadWorks”, algorithm=MD5, uri=“sip:sip.broadvoice.com”, nonce=“BroadWorksXgux6zemmTcc0sniBW”, response=“75b0680729b173a3a226752221cd92bf”, qop=auth, cnonce=“4359ff24”, nc=00001aca
Expires: 1800
Contact: sip:4251231234@209.177.14.14:5060
Content-Length: 0


<— SIP read from UDP:147.135.20.221:5060 —>
SIP/2.0 200 OK
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Contact: sip:4251231234@209.177.14.14:5060
Expires: 30
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Really destroying SIP dialog ‘53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com’ Method: REGISTER
asteriskbox*CLI> sip show registry
Host dnsmgr Username Refresh State Reg.Time
yahyabroadvoice:5060 N 4251231234@s 24 Request Sent Tue, 15 Nov 2011 10:29:28
1 SIP registrations.
Retransmitting #5 (no NAT) to 147.135.20.221:5060:
REGISTER sip:sip.broadvoice.com SIP/2.0
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Max-Forwards: 70
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
User-Agent: Asterisk PBX 1.8.7.1
Authorization: Digest username=“4251231234”, realm=“BroadWorks”, algorithm=MD5, uri=“sip:sip.broadvoice.com”, nonce=“BroadWorksXgux6zemmTcc0sniBW”, response=“75b0680729b173a3a226752221cd92bf”, qop=auth, cnonce=“4359ff24”, nc=00001aca
Expires: 1800
Contact: sip:4251231234@209.177.14.14:5060
Content-Length: 0


<— SIP read from UDP:147.135.20.221:5060 —>
SIP/2.0 200 OK
Call-ID: 53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com
CSeq: 7014 REGISTER
From: sip:4251231234@sip.broadvoice.com;tag=as7b9fc860
To: sip:4251231234@sip.broadvoice.com
Via: SIP/2.0/UDP 209.177.14.14:5060;branch=z9hG4bK1a79f404
Contact: sip:4251231234@209.177.14.14:5060
Expires: 30
Content-Length: 0

<------------->
— (9 headers 0 lines) —
Scheduling destruction of SIP dialog ‘53b8ecd02425cb3f7f94121331ffb97a@sip.broadvoice.com’ in 32000 ms (Method: REGISTER)
[Nov 15 10:30:04] NOTICE[2426]: chan_sip.c:20152 handle_response_register: Outbound Registration: Expiry for yahyabroadvoice is 30 sec (Scheduling reregistration in 24 s)

[/code]

It retransmits the REGISTER request 5 times, and takes around 4-5 seconds to do so. During this time sip show registry shows status as ‘Request sent’. After that the status is ‘REGISTERED’ and I can make and receive calls ok. The problem is I need to have two other Broadvoice accounts registering from the same Asterisk box, and when I add them, Broadvoice stops responding to my server after a few minutes. sip show registry then shows status as ‘Failed’. I think this is due to Broadvoice firewalls blocking my IP on seeing too many REGISTER requests (5x3=15) every 30s. If I switch to another Broadvoice proxy it starts working again (for a few minutes if all 3 accounts are enabled)

I did set defaultexpiry in sip.conf to 1800 to try and reduce the number of REGISTERs, but Broadvoice insists on sending 30s Expires header in the response. Looks like Expires header in the request is just a suggestion.

I’m seeing this issue since I moved to a new VPS provider (vr.org) and also migrated from Asterisk 1.2 to 1.8 at the same time. I have not yet set up any firewall rules, although my VPS provider may have some set up outside my server.

Thanks for any help.


#2

I just found this in the wiki, which may be relevant to my issue:

https://wiki.asterisk.org/wiki/display/AST/chan_sip+Transaction+Support+Proprosal

[quote]5. What does chan_sip currently do instead of using a transaction layer?

chan_sip, instead of maintaining a full transaction layer, tries to identify incoming retransmissions and marks them with an “ignore” flag. Then, in every request/response handling function where we think it might be important, we try to handle falling through the code to “do the right thing.” This has led to many, many bugs. Many times we end up trying to reconstruct the same response to a request based on some state that isn’t guaranteed not to have changed. The core code, in most circumstances should not even be aware that a retransmission has been received, let alone make a response to it one.

For retransmitting messages that chan_sip’s UA code sends, chan_sip relies on the retrans_pkt function which is scheduled to run from sip_reliable_xmit.[/quote]


#3

Also just discovered this sip show history command. Hope this helps…

asteriskbox*CLI> sip show history 4a84961d09c778d3229ed18a2ce5ad0d@sip.broadvoice.com

  * SIP Call
1. RegistryInit    Account: 4251231234@yahyabroadvoice
2. AuthResp        Auth response sent for 4251231234 in realm BroadWorks - nc 155
3. TxReqRel        REGISTER / 257 REGISTER - REGISTER
4. ReTx            1000 REGISTER sip:sip.broadvoice.com SIP/2.0
5. ReTx            2000 REGISTER sip:sip.broadvoice.com SIP/2.0
6. ReTx            4000 REGISTER sip:sip.broadvoice.com SIP/2.0
7. ReTx            4000 REGISTER sip:sip.broadvoice.com SIP/2.0
8. ReTx            4000 REGISTER sip:sip.broadvoice.com SIP/2.0
9. Rx              SIP/2.0 / 257 REGISTER / 200 OK
10. SchedDestroy    32000 ms