[ULTRAMONKEY-USERS] Bug in real server health check when running asterisk with ultramonkey load balancing
Madhuri Patwardhan
madhuri_patwardhan at yahoo.com
Tue May 6 16:42:33 EST 2008
I found a bug when trying to get Asterisk working with
Ultramonkey. After fixing this bug I have Asterisk
working with Ultramonkey doing load balancing and
heartbeat without any problem.
The bug:
Asterisk real server health check does not work
reliabily from Ultramonkey. ldirectord from
ultramonkey sends SIP OPTIONS request for real server
health ckeck. Many a times Asterisk sends "200 OK"
response for this request on a wrong port. So, the
real server is deactivated.
Here are the details:
- Ultramonkey could set up to use SIP OPTIONS request
for Asterisk real server health check. When you do
that the script /etc/ha.d/resource.d/ldirectord uses
the same call-id for all the OPTIONS requests it
sends.
- In Asterisk, in chan_sip.c, when it receives a new
SIP request it tries to see if there is an existing
dialog setup for this request. If it doesn't find the
exising dialog it will setup the new dialog. Since
call-id, to, from and Cseq are same for every request
sent from ldirectord it sometimes picks up the wrong
earlier dialog and sends the response to this request
on the wrong port.
- ldirectord never receives response in the above case
and marks the real server down.
Solution:
Modify ldirectord to generate new call-id for each
request. Here is the modified code for ldirectord.
After this change there is no problem in real server
health check.
Here is a quick modififications to ldirectord,
check_sip subroutine. You can use any method to
generate different call-id. I have used the following
method.
my $range = 100000000000;
my $callid = int(rand($range));
my $request =
"OPTIONS sip:" . $$v{login} . "
SIP/2.0\r\n" .
"Via: SIP/2.0/UDP
$sip_s_addr_str:$sip_s_port;" . "rport;" .
"branch=z9hG4bKhjhs8ass877\r\n"
.
"Max-Forwards: 70\r\n" .
"To: <sip:" . $$v{login} . ">\r\n" .
"From: <sip:" . $$v{login} .
">;tag=1928301774\r\n" .
"Call-ID: $callid\r\n" .
"CSeq: 63104 OPTIONS\r\n" .
"Contact: <sip:" . $$v{login} . ">\r\n"
.
"Accept: application/sdp\r\n" .
"Content-Length: 0\r\n\r\n";
If anybody wants full details of how to get Asterisk
working with ultramonkey load balancing and heartbeat
let me know.
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
More information about the Ultramonkey-users
mailing list