[asterisk-users] Dealing with 2 SIP providers
Mike
list at virtutel.ca
Sun May 13 16:18:21 MST 2007
Wow, thanks for the detailed response. For your last question, on why I
want to put a forced delay of 30 seconds, it's because the example I gave
was quite simplified to isolate what my real issue was. In reality there
are cases where I want to force 30 seconds before hanging up, and other
cases where I will let the caller decide when he's giving up.
Chris, I really do appreciate your help. I haven't used AEL yet, if is
ready for production at this point? (a while ago it was recommended not to
use it). I ask this because I find this method of writing code MUCH easier
then a sort of
programming with every line numbered like BASIC....
Can you easily mix and match AEL and standard Asterisk (i.e. my old code
with new code I would put in?)
Mike
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Chris Bagnall
Sent: Friday, May 11, 2007 22:22
To: 'Asterisk Users Mailing List - Non-Commercial Discussion'
Subject: RE: [asterisk-users] Dealing with 2 SIP providers
> What I mean is I want a call to go out on ProviderA, UNLESS it's down
> and then go to ProviderB.
> I want it to ring 30 seconds and then Hangup if nobody has answers.
This one's actually a bit more complicated than it first seems, since you
need to know how each provider reports status when it's unavailable. We run
the following AEL macros to achieve something similar:
(apologies to the list for the big chunk of code below - I'm not sure how
well/if the list handles attachments)
// DIAL NUMBER (with a range of routing options) macro outbound (number,
route1, route2, route3, route4, route5) {
// set correct outbound caller id
if (${LEN(${CALLERID(number)})} < 10 & ${LEN(${CALLERID(number)})} >
0) {
if (${LEN(${DB(callerid/${CDR(accountcode)})})} > 9) {
CALLERID(number)=${DB(callerid/${CDR(accountcode)})};
} else
Set(CALLERID(number)=);
};
dialstart:
switch (${route1}) {
case dundi:
if (${number:0:2} = 00) {
&dundi-e164 (${number:2});
} else if (${number:0:1} = 0) {
&dundi-e164 (44${number:1});
} else
&dundi-e164 (${number});
break;
case provider1:
&dialout (IAX2/provider1/${number});
break;
case provider2:
&dialout (IAX2/provider2/${number});
break;
case provider3:
&dialout (IAX2/provider3/${number});
break;
case pstn:
&dialout (Zap/g1/${number});
break;
default:
NoOp (invalid route: ${route1});
};
if (${LEN(${route2})} > 0) {
route1=${route2};
} else {
Playtones (congestion);
Congestion ();
};
if (${LEN(${route3})} > 0)
route2=${route3};
if (${LEN(${route4})} > 0)
route3=${route4};
if (${LEN(${route5})} > 0)
route4=${route5};
goto dialstart;
};
// DIAL NUMBER (ignoring anything except busy) macro dialout (dialstring) {
Dial (${dialstring},,TW);
switch (${DIALSTATUS}) {
case BUSY:
Playtones (busy);
Busy ();
break;
case CONGESTION:
Playtones (busy);
Busy ();
break;
};
};
You can then dial from your "main" dialplan something like this for UK
landlines:
exten => _0[12]XXXXXXXXX,1,Macro(outbound,${EXTEN},provider1,provider2,pstn)
The "dialout" macro ignores any responses from the SIP/IAX provider except
Busy or Congestion (we have a provider which provides "congestion" when the
dialled number is busy, that's why it's there). So, if the provider's server
is unavailable (through qualify=yes or whatever), it'll fall through as
channel status "unknown" and loop onto the next provider.
On an outbound call made from one of your users, why would you want a 30
second timeout? Surely you'd want to keep ringing the callee until the
caller (i.e. your user) loses interest and hangs up their device? The length
of time for a device to be rung before doing something else is usually
determined by the recipient, not the initiator.
Hope that helps.
Regards,
Chris
--
C.M. Bagnall, Director, Minotaur I.T. Limited For full contact details visit
http://www.minotaur.it/chris.html This email is made from 100% recycled
electrons
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
More information about the asterisk-users
mailing list