For what ever reason I can't get this to work with Asterisk 1.0.x release, but it work on Asterisk 1.2.x release. They both are using the same configuration and the only difference is Asterisk 1.0.x release was using AST_DATA to talk to Postgres, and Asterisk 1.2.x is using Unix_odbc to talk to Postgres. Anyway I am not very sure why one work and one doesn't but it work great now. =)
 
On 3/1/06, Chan, Ka Lun <kchan1028@gmail.com > wrote:
Hi All,
 
    I am trying to set up SER with Dispatcher to loadbalancing the traffic to 2 * boxes. SER was able to select the * IPs from the dispatcher.list, but * SIP response back authentication required. It work perfectly if I i use rewritehostport instead of using the dispatch module. I am pulling my hair now and still don't know where the problem at.
 
openser.cfg
        if (uri=~"sip:\+?[1-9][0-9]*@.*") {
                ds_select_dst("2", "0");
                route(4);
                route(5);
                return;
        };
 
route[4] {
 

        if (isflagset(6)) {
                force_rport();
                fix_nated_contact();
                force_rtp_proxy();
        };
}
 
route[5] {
 
        setflag(1);
        t_on_reply("1");
        forward(uri:host, uri:port);
        append_hf("P-hint: main PSTN route\r\n");
        t_on_failure("1");
        if (!t_relay()) {
                sl_reply_error();
                return;
        };
}
 
onreply_route[1] {
 
        if (isflagset(6) && status=~"(180)|(183)|2[0-9][0-9]") {
                if (!search("^Content-Length:[ ]*0")) {
                        force_rtp_proxy();
                };
        };
 
        if (nat_uac_test("1")) {
                fix_nated_contact();
        };
}
 
failure_route[1] {
 
       append_hf("P-hint: backup PSTN route\r\n");
       rewritehost("x.x.x.x");
       rewriteport(   "5060");
       append_branch();
        t_relay();
}
 
SIP.conf form *
[general]
host=dynamic
bindaddr=0.0.0.0
port=5060
useragent=x
context=default
disallow=all
allow=g729
allow=ulaw
autocreatepeer=yes
dtmfmode=rfc2833
qualify=no
nat=yes
canreinvite=no
 
 
Retransmitting #5 (no NAT):
SIP/2.0 407 Proxy Authentication Required
Via: SIP/2.0/UDP x.x.x.x;branch=0
Via: SIP/2.0/UDP 192.168.1.107:5060;received=x.x.x.x;branch=z9hG4bK263724
From: "testing" <sip:testing@64.127.123.100 >;tag=5318
To: < sip:exten@x.x.x.x>;tag=as1cf1692c
Call-ID: 1141227578-724-TF-GIXXER@192.168.1.107
CSeq: 813 INVITE
User-Agent: x
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER
Contact: < sip:exten@x.x.x.x>
Proxy-Authenticate: Digest realm="asterisk", nonce="40a9764f"
Content-Length: 0