DNS SRV failover not working in asterisk

2.3k views Asked by At

I have added following two DNS SRV records (with TTL 10 seconds) for testing:

_sip._udp.example.com.  SRV   1   0  5060   sip101.example.com.
_sip._udp.example.com.  SRV   2   0  5060   sip102.example.com.

Both sip101.example.com and sip102.example.com are valid A records of two Asterisk servers(version 11.17.1).

I am sending call from another Asterisk server (version 11.17.1) with IP X.X.X.X with following dialplan:

[default]
exten => 0900,1,NoOP(This is test call for checking DNS SRV example.com)
exten => 0900,n,Dial(SIP/[email protected])

Following is the configuration of extension which is sending calls:

[XXXX]
type=friend
username=XXXX
secret=temp
host=dynamic
context=default
canreinvite=no
srvlookup=yes
qualify=yes
nat=force_rport,comedia

For testing failover of DNS SRV, I have disabled Asterisk on sip101.example.com which is on first priroty; so after no response till 10 seconds on sip101.example.com, it should failover to sip102.example.com.

But its not failing over to second priority Asterisk but times out as following:

== Using SIP RTP CoS mark 5
-- Executing [0900@default:1] NoOp("SIP/XXXX-0000014e", "This is test call for checking DNS SRV example.com") in new stack
-- Executing [0900@deafult:2] Dial("SIP/XXXX-0000014e", "SIP/[email protected]") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/[email protected]
-- SIP/example.com-0000014f is circuit-busy
== Everyone is busy/congested at this time (1:0/1/0)
-- Auto fallthrough, channel 'SIP/XXXX-0000014e' status is 'CONGESTION'
-- Executing [h@default:1] Hangup("SIP/XXXX-0000014e", "") in new stack
== Spawn extension (default, h, 1) exited non-zero on 'SIP/XXXX-0000014e'
[Jan  3 13:48:43] WARNING[3168]: chan_sip.c:4024 retrans_pkt: Retransmission timeout reached on transmission [email protected]:5060 for seqno 102 (Critical Request) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
Packet timed out after 32000ms with no response

Can anyone help me with this issue?

3

There are 3 answers

1
Konstantin Suvorov On BEST ANSWER

Some googling (1, 2, 3, 4) suggests that in older versions:

Asterisk only reads the first SRV entry without bothering with priorities and weights.

So you may want to try it with Asterisk 13 and PJSIP.

0
arheops On

Asterisk will not go second priority. It do only one attempt. If you need second attempt(to other ip), you have do second call in dialplan.

If you using chan_sip second call will be resolved to first SRV record too. With pjsip it MAY switch(but not granted).

If you need garanted switch, use different dns names or ips and do failover in dialplan(check extensions.conf.sample for example).

0
Azhar Nawaz On

Thanks Guys for sending me replies.

It is clear now that Asterisk 11.17.2 does not have capacity to resolve multiple DNS SRV records.

For further testing, I switch the client (Traffic Generator) which sends calls to DNS SRV asterisk from Asterisk 11.17 to Freeswitch 1.7 and it works perfectly.

Freeswitch was successfully sending/failovering calls to DNS SRV i.e. example.com. But still have one issue, Freeswitch never sends calls back to primary node after its recovery. It needs a Freeswitch restart to again select primary node to send calls.