<p>Hello I use this version of kamailio<br>
 kamailio -v<br>
version: kamailio 4.3.0-dev3 (x86_64/linux) 8cdbe7<br>
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<br>
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB<br>
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.<br>
id: 8cdbe7<br>
compiled on 17:54:50 Jan 20 2015 with gcc 4.8.2</p>

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

<p>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)</p>

<p>My alg is here:</p>

<p>{</p>

<pre><code>        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;

    }
}
</code></pre>

<p>}</p>

<p>branch_route[1]{</p>

<pre><code>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");
}
</code></pre>

<p>} </p>

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

<p>At the kamailio console I see output</p>

<p>This is output of alg that above.</p>

<p>I have 3 devices: 2 websocket devices and 1 udp<br>
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.<br>
You can see start of every branch from words of log "Websocket Branch is" or "UDP Branch is"</p>

<p>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.<br>
(you can see it reply at the log)</p>

<p>Feb  8 23:04:43 Kamailio2 kamailio[59406]: INFO: </p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/issues/72">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZajNRzw7xTN_mDealpoheTuz5gfVks5nqAdTgaJpZM4DdfSA.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
  <div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
    <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/72"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>