SIP Trunk Incoming Call Failover

Hi Guys,

I have an Asterisk server passing calls to an Avaya Communication Manager. One SIP trunk is registered to one Avaya CLAN while another trunk is registered to a different CLAN.

I’m trying to failover incoming calls if one trunk is unreachable.

Below is from my extensions.conf setup


When I dial the 05 number I receive the below error - am I missing something?

-- Executing [05xxxxxx@sipprovider:1] Answer("SIP/sipprovider-0000000d", "") in new stack
-- Auto fallthrough, channel 'SIP/sipprovider-0000000d' status is 'UNKNOWN'

Thanks for any help

You need a pattern that matches the extension number on every line, or you need to use “same”.

thanks - I’ve made it a little further - I have my AvayaTrunk2 in an unreachable state -

AvayaTrunk2 a 5060 UNREACHABLE

However when I call in now it doesn’t route to AvayaTrunk which is available as per the gotoif

-- Executing [05xxxxxx@sipprovider:1] Answer("SIP/sipprovider-00000012", "") in new stack
-- Executing [05xxxxxx@sipprovider:2] Set("SIP/sipprovider-00000012", "NETWORKSTATUS=UNREACHABLE") in new stack
-- Executing [05xxxxx@sipprovider:3] GotoIf("SIP/sipprovider-00000012", "0?101") in new stack
-- Executing [05xxxxx@sipprovider:4] Dial("SIP/sipprovider-00000012", "SIP/1097@AvayaTrunk2") in new stack

[Aug 21 16:59:28] WARNING[16211][C-00000015]: app_dial.c:2437 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)

My modified code as per your same recommendation:


Any ideas at all? thanks a lot

That normally results when a dynamic peer fails to register, but you would normally use a static address in this case.

yes both peers are on static addresses - I have purposely put AvayaTrunk2 into an UNREACHABLE state to test the failover to AvayaTrunk. Any ideas as to why it is not failing over when I dial? Thanks again!

Because the qualify poll hasn’t been done since you created the fault. In general, you should do the dial and then handle the failure, rather than try to pre-empt the result of the dial.

In this case, I suspect that the qualify was done between the test and the Dial, as I have a feeling that a timeout on the Dial woudl produce a different error, but I could be wrong.

Actually, there is an error in the expression. You are comparing the string NETWORKSTATUS against the string UNREACHABLE, which will never be true, rather than comparing a variable against a string.

This doesn’t invalidate the fact that you should try the Dial and analyze the error, if you want to avoid race conditions

I got this working thanks for your help - as you said it was best to dial the peer first and then catch the error. I tweaked the code slightly also changing to dialstatus and channel unavailable.

Below is the working code in case anyone else is interested - this receives a call on AvayaTrunk2 and if not available tries AvayaTrunk instead.