Hello I use this version of kamailio
kamailio -v
version: kamailio 4.3.0-dev3 (x86_64/linux) 8cdbe7
flags: STATS: Off, USE_TCP, USE_TLS, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, F_MALLOC, DBG_F_MALLOC, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 8cdbe7
compiled on 17:54:50 Jan 20 2015 with gcc 4.8.2

I hav an issue with append branches to branch route when I need fork call to one endpoint woth different destionations.

I use my own algorithm for call to this devices because with lookup("location") I can not use RTPENGINE for different types of endpoints (web endoints and standart UDP endpoints)

My alg is here:

{

        sql_query("ca", "select contact from location where username='$tU'", "ra");
        xlog("L_INFO","rows: $dbr(ra=>rows) cols: $dbr(ra=>cols)\n");
        if($dbr(ra=>rows)>0){
            $var(i)=0;
             while($var(i)<$dbr(ra=>rows)){

                xlog("L_INFO","SQL query return contact {$dbr(ra=>[$var(i),0])} for {$tU} at step {$var(i)}\n");

                if ($dbr(ra=>[$var(i),0])=~"transport=ws"){ 
                    xlog("L_INFO", "This is a Websocket call to endpoint");
                    sql_pvquery("ca", "select received from location where contact='$dbr(ra=>[$var(i),0])'","$var(recieved)");

                    $du=$var(recieved);
                    xlog("L_INFO","SQL query return recieved {$var(recieved)} for {$tU}. Destination is {$du}\n");


                        append_branch("sip:$tU@$(du{s.select,1,:})");


                }

                else
                {   

                    xlog("L_INFO", "This is a classic UDP call to endpoint");
                    $var(recieved)='';
                    sql_pvquery("ca", "select received from location where contact='$dbr(ra=>[$var(i),0])'","$var(recieved)");
                    xlog("L_INFO", "SQL query return RECIEVED {$var(recieved)}");
                    if ($var(recieved)==0){
                        xlog("L_INFO", "Recieved string is EMPTY");
                        $du="sip:"+$(dbr(ra=>[$var(i),0]){s.select,1,@});
                    }
                    else {
                        xlog("L_INFO", "Recieved string is {$var(recieved)}");
                        $du=$var(recieved);
                    }
                    $var(UDP_contact)="sip:"+$(dbr(ra=>[$var(i),0]){s.select,1,@});                     

                            append_branch("sip:$tU@$(du{s.select,1,:})");

                    xlog("L_INFO","Classic Destination URI is {$dbr(ra=>[$var(i),0])} for {$tU}}. Destination is {$du}\n");
                }
                $var(i) = $var(i) + 1;

            }   
        }
        else{
        exit;
        }
        t_on_branch("1");
        return;

    }
}

}

branch_route[1]{

if($du=~"transport=ws"){
        xlog("L_INFO","Websocket Branch is {$du} for {$tU}\n");

        rtpengine_manage("internal extenal force trust-address replace-origin replace-session-connection ICE=force RTP/SAVPF");
        t_on_reply("REPLY_FROM_WS");

        }
else{
        xlog("L_INFO","UDP Branch is {$du)} for {$tU}\n");

        rtpengine_manage("replace-origin replace-session-connection ICE=remove RTP/AVP");
        t_on_reply("MANAGE_CLASSIC_REPLY");
}

}

So as you see I choose array of devices and then set its to branches.

At the kamailio console I see output

This is output of alg that above.

I have 3 devices: 2 websocket devices and 1 udp
But when you look at dump where rtpengine make changes with packets you can see that it runs for 4 devices and 1 and 4 devices is the same.
You can see start of every branch from words of log "Websocket Branch is" or "UDP Branch is"

So this bug gives a mistake because some of hardphones can not handlie double INVITE and kamilio response for this devices cancel with 200 cause because hardphone set 482 reply to kamialio.
(you can see it reply at the log)

Feb 8 23:04:43 Kamailio2 kamailio[59406]: INFO:


Reply to this email directly or view it on GitHub.