<p>Hello. I need parallel forking calls with the  same username. (Call to all contacts with name for example User123), my endpoints may be  WebSocket based and standart UDP endpoints. And I use rtpengine_manage for managing calls wor webphones and standart softh/hard phones.</p>

<p>I get all contacts manually and than at the branch route set rtpengine_manage settings for every call.</p>

<p>It works fine but it works for one kamailio server. </p>

<p>When I use 2 kamailio servers as load balansers Server that handle call get all endpoints from location but call to only one, that registred only at ths server</p>

<p>for example I call user123<br>
I have 3 contacts<br>
user123@1.2.3.4 - was registered at kamailio 1<br>
user123@3.2.1.4 - was registered at kamailio 2<br>
user123@4.3.2.1 - was registered at kamailio 1</p>

<p>So if call goes through kamailio 1 it call only to user123@1.2.3.4 and user123@4.3.2.1</p>

<p>I use this settings for usrloc  at 2 kamailios to share all table between 2 servers</p>

<p>modparam("usrloc", "db_url", DBURL)<br>
modparam("usrloc", "db_mode", 3)<br>
modparam("usrloc", "user_column", "username")<br>
modparam("usrloc", "contact_column", "contact")<br>
modparam("usrloc", "expires_column", "expires")<br>
modparam("usrloc", "q_column", "q")<br>
modparam("usrloc", "callid_column", "callid")<br>
modparam("usrloc", "cseq_column", "cseq")<br>
modparam("usrloc", "methods_column", "methods")<br>
modparam("usrloc", "cflags_column", "cflags")<br>
modparam("usrloc", "user_agent_column", "user_agent")<br>
modparam("usrloc", "received_column", "received")<br>
modparam("usrloc", "socket_column", "socket")<br>
modparam("usrloc", "path_column", "path")<br>
modparam("usrloc", "ruid_column", "ruid")<br>
modparam("usrloc", "instance_column", "instance")<br>
modparam("usrloc", "use_domain", 1)</p>

<p>and this code for calling them</p>

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

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

            }

        }
        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>When it try to branch endpoint without registration at server that handle call I get errors that tm module can not build Via header </p>

<p><em>via_builder(): TCP/TLS connection (id: 0) for WebSocket could not be<br>
 found</em><br>
 <em>ERROR:  [msg_translator.c:1725]: build_req_buf_from_sip_req():<br>
 could not create Via header</em><br>
 <em>ERROR:  [forward.c:607]: forward_request(): ERROR:<br>
 forward_request: building failed</em></p>

<p>UDP calls get errors something like above (sorry than can not share error code, This situation not often).</p>

<p>So I think I have this trouble because I use manually handling call and tried to substitute to lookup_branches function. but I have no Idea how to set rtpengine_manage paraments for each endpoint depending this is websocket or standart call.</p>

<p>IF there is write problem for callings thhrough 2 kamailios as load balansers please let me know about how to set rtpengine_manage parametrs wor endpoints for every fork.  If not- can you tell me how I can call to all endpoints endepending of registration server (kamailio 1 or 2).</p>

<p>But with another side I can not understand why kamailio 2 don't see registrations at kamailio1 (or 1 from 2). May be this is trouble of usrloc module. That's why I write this problem here.<br>
Thanks.</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/53">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZQm9cBS6iDeq64o6oHXPjODCsQGJks5nmP39gaJpZM4DYaRI.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/53"></link>
    <meta itemprop="name" content="View Issue"></meta>
  </div>
  <meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>