<div dir="ltr">Hi Daniel,<div><br></div><div>thanks for you e-mail... i will try that approach.</div><div><br></div><div>in the main time i exploited the "received" parameter in route header sent by freeswitch and with a bit of manipulation i managed to rout the call back to WS client :=)</div><div><br></div><div>Im will definitely try to enable r2 and come back with the  results.</div><div><br></div><div><br></div><div>--- snip ---</div><div><br></div><div><div>route[SIPOUT] {</div><div>        if (!uri==myself) {</div><div><br></div><div><br></div><div>                xlog("L_INFO", "ROUTE HEADER value: $hdr(Route)\n");</div><div><br></div><div><br></div><div>                $var(rcv_regex)= $(hdr(Route){re.subst,/.*received=(.*)/\1/});</div><div><br></div><div>                $var(ip)= $(var(rcv_regex){s.select,0,~});</div><div>                $var(port)= $(var(rcv_regex){s.select,1,~});</div><div>                $var(proto_number)= $(var(rcv_regex){s.select,2,~});</div><div><br></div><div>                if ($var(proto_number) == "1") {</div><div>                        $var(trans) = "UDP";</div><div><br></div><div>                } else if ($var(proto_number) == "6" ) {</div><div>                        $var(trans) = "ws";</div><div><br></div><div>                } else {</div><div>                        # not interested for now</div><div>                        

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">$var(trans) = "TCP";</span>

</div><div>                }</div><div><br></div><div>                $var(request_route_regex) = $var(ip) + ":" + $var(port) + ";transport=" +$var(trans);</div><div><br></div><div>                xlog("L_INFO", "ROUTE HEADER - rcv_regex: $var(rcv_regex)\n");</div><div>                xlog("L_INFO", "ROUTE HEADER - request route : $var(request_route_regex)\n");</div><div><br></div><div><br></div><div>                append_hf("P-hint: outbound\r\n");</div><div>                $ru="sip:" + $rU + "@"+$var(request_route_regex);</div><div>                xlog("SCRIPT: Request uri = $ru\n");</div><div>                route(RELAY);</div><div>        }</div><div>}</div></div><div><br></div><div>--- snip ---</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 13 February 2018 at 11:48, Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p>Hello,</p>
    <p>you have an explicit set of $fs, which is setting the send
      socket. You have to do then when receiving from WS, not when going
      to WS.</p>
    <p>In 5.1, you can try to enable:</p>
    <p>  -
<a class="m_5960866116094684756moz-txt-link-freetext" href="https://www.kamailio.org/docs/modules/stable/modules/path.html#path.p.enable_r2" target="_blank">https://www.kamailio.org/docs/<wbr>modules/stable/modules/path.<wbr>html#path.p.enable_r2</a></p>
    <p>and then let kamailio do all about send socket (remove the
      assignments to $fs).</p>
    <p>Cheers,<br>
      Daniel<br>
    </p><div><div class="h5">
    <br>
    <div class="m_5960866116094684756moz-cite-prefix">On 09.02.18 22:57, Tihomir Culjaga
      wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <div dir="ltr">
        <div>Hi,</div>
        <div><br>
        </div>
        <div>Im new to Kamailio so im sorry if some of my questions will
          sound a bit wierd :=)</div>
        <div><br>
        </div>
        <div>i have a setup like this: (Kamailio version 5.1)</div>
        <div><br>
        </div>
        <div>UA > Kamailio > Freeswitch</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Kamailio forwards registration to freeswitch without saving
          location.</div>
        <div><br>
        </div>
        <div>I have configured sip over websockets and im able to
          register to Freeswitcha via kamailio.</div>
        <div>Also, i use add_path_received() so kamailio adds a path
          header to register messages</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>
          <div>recv 945 bytes from udp/[192.168.50.60]:5060 at
            22:38:07.283809:</div>
          <div> 
 -----------------------------<wbr>------------------------------<wbr>-------------</div>
          <div>   REGISTER <a class="m_5960866116094684756moz-txt-link-freetext">sip:192.168.50.60</a> SIP/2.0</div>
          <div>   Via: SIP/2.0/UDP
            192.168.50.60;branch=<wbr>z9hG4bKa929.<wbr>0f66d60c4333f4a3a9d83d41a63295<wbr>d9.0</div>
          <div>   Via: SIP/2.0/WSS
            192.0.2.110;rport=63296;<wbr>received=192.168.200.77;<wbr>branch=z9hG4bK6931435</div>
          <div>   Max-Forwards: 69</div>
          <div>   To: <<a href="mailto:sip%3A1001@192.168.50.60" target="_blank">sip:1001@192.168.50.60</a>></div>
          <div>   From: <<a href="mailto:sip%3A1001@192.168.50.60" target="_blank">sip:1001@192.168.50.60</a>>;tag=<wbr>vq30modpgd</div>
          <div>   Call-ID: dlnrna9o4ngn25fb9d1vi2</div>
          <div>   CSeq: 196 REGISTER</div>
          <div>   Authorization: Digest algorithm=MD5, username="1001",
            realm="192.168.50.60",
            nonce="744aaa14-4a86-4ce3-<wbr>b6d6-419b0a34ee90",
            uri=<a class="m_5960866116094684756moz-txt-link-rfc2396E">"sip:192.168.50.60"</a>,
            response="<wbr>9b592b874474d4ffe5769f2410bace<wbr>ef", qop=auth,
            cnonce="sf7ff0fp8tm5", nc=00000001</div>
          <div>   Contact: <<a href="mailto:sip%3A1001@192.0.2.110" target="_blank">sip:1001@192.0.2.110</a>;<wbr>transport=ws>;reg-id=1;+sip.<wbr>instance="<urn:uuid:587f4694-<wbr>7e55-46dc-a858-579a82556a20>";<wbr>expires=600</div>
          <div>   Allow:
            ACK,CANCEL,INVITE,MESSAGE,BYE,<wbr>OPTIONS,INFO,NOTIFY,REFER</div>
          <div>   Supported: path, gruu, 100rel, outbound</div>
          <div>   User-Agent: SIP.js/0.7.0 BB</div>
          <div>   Content-Length: 0</div>
          <div>   Path:
            <a class="m_5960866116094684756moz-txt-link-rfc2396E"><sip:192.168.50.60;lr;<wbr>received=192.168.200.77~63296~<wbr>6></a></div>
          <div>   </div>
          <div> 
 -----------------------------<wbr>------------------------------<wbr>-------------</div>
          <div>send 719 bytes to udp/[192.168.50.60]:5060 at
            22:38:07.329444:</div>
          <div> 
 -----------------------------<wbr>------------------------------<wbr>-------------</div>
          <div>   SIP/2.0 200 OK</div>
          <div>   Via: SIP/2.0/UDP
            192.168.50.60;branch=<wbr>z9hG4bKa929.<wbr>0f66d60c4333f4a3a9d83d41a63295<wbr>d9.0</div>
          <div>   Via: SIP/2.0/WSS
            192.0.2.110;rport=63296;<wbr>received=192.168.200.77;<wbr>branch=z9hG4bK6931435</div>
          <div>   From: <<a href="mailto:sip%3A1001@192.168.50.60" target="_blank">sip:1001@192.168.50.60</a>>;tag=<wbr>vq30modpgd</div>
          <div>   To: <<a href="mailto:sip%3A1001@192.168.50.60" target="_blank">sip:1001@192.168.50.60</a>>;tag=<wbr>Spya88DKU9gSQ</div>
          <div>   Call-ID: dlnrna9o4ngn25fb9d1vi2</div>
          <div>   CSeq: 196 REGISTER</div>
          <div>   Contact: <<a href="mailto:sip%3A1001@192.0.2.110" target="_blank">sip:1001@192.0.2.110</a>;<wbr>transport=ws>;expires=600</div>
          <div>   Date: Fri, 09 Feb 2018 21:38:07 GMT</div>
          <div>   User-Agent:
            FreeSWITCH-mod_sofia/1.6.19+<wbr>git~20171120T163416Z~<wbr>b1b21d0695~64bit</div>
          <div>   Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE,
            INFO, UPDATE, REGISTER, REFER, NOTIFY</div>
          <div>   Supported: timer, path, replaces</div>
          <div>   Path:
            <a class="m_5960866116094684756moz-txt-link-rfc2396E"><sip:192.168.50.60></a>;lr;<wbr>received=192.168.200.77~63296~<wbr>6</div>
          <div>   Content-Length: 0</div>
          <div>   </div>
          <div> 
 -----------------------------<wbr>------------------------------<wbr>-------------</div>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Once, registered, im trying to originate a call to the
          registered endpoint from freeswitch</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>this results in an invite like this:</div>
        <div><br>
        </div>
        <div>
          <div>send 1757 bytes to udp/[192.168.50.60]:5060 at
            22:46:21.252549:</div>
          <div> 
 -----------------------------<wbr>------------------------------<wbr>-------------</div>
          <div>   INVITE <a href="mailto:sip%3A1001@192.0.2.110" target="_blank">sip:1001@192.0.2.110</a>;<wbr>transport=ws
            SIP/2.0</div>
          <div>   Via: SIP/2.0/UDP
            192.168.50.65:15060;rport;<wbr>branch=z9hG4bKXHcX316pDgXZB</div>
          <div>   Route:
            <a class="m_5960866116094684756moz-txt-link-rfc2396E"><sip:192.168.50.60></a>;lr;<wbr>received=192.168.200.77~63296~<wbr>6</div>
          <div>   Max-Forwards: 70</div>
          <div>   From: "" <<a href="mailto:sip%3A1002@192.168.50.65" target="_blank">sip:1002@192.168.50.65</a>>;tag=<wbr>tZQ393yprj7BK</div>
          <div>   To: <<a href="mailto:sip%3A1001@192.0.2.110" target="_blank">sip:1001@192.0.2.110</a>;<wbr>transport=ws></div>
          <div>   Call-ID: 8212b700-8885-1236-08b3-<wbr>000c293ae94e</div>
          <div>   CSeq: 118770326 INVITE</div>
          <div>   Contact: <<a href="http://sip:mod_sofia@192.168.50.65:15060" target="_blank">sip:mod_sofia@192.168.50.65:<wbr>15060</a>></div>
          <div>   User-Agent:
            FreeSWITCH-mod_sofia/1.6.19+<wbr>git~20171120T163416Z~<wbr>b1b21d0695~64bit</div>
          <div>   Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE,
            INFO, UPDATE, REGISTER, REFER, NOTIFY</div>
          <div>   Supported: timer, path, replaces</div>
          <div>   Allow-Events: talk, hold, conference, refer</div>
          <div>   Content-Type: application/sdp</div>
          <div>   Content-Disposition: session</div>
          <div>   Content-Length: 891</div>
          <div>   X-FS-Support: update_display,send_info</div>
          <div>   Remote-Party-ID: <<a href="mailto:sip%3A1002@192.168.50.65" target="_blank">sip:1002@192.168.50.65</a>>;<wbr>party=calling;screen=yes;<wbr>privacy=off</div>
        </div>
        <div><br>
        </div>
        <div>Freeswitch appends a route header to the invite specifying
          kamailio as route and a received with original uri.</div>
        <div><br>
        </div>
        <div>well, here is the issue ... im failing to hit the SIP over
          websocket client... Kamailio </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>my RELAY route is like this</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>
          <div>route[RELAY] {</div>
          <div><br>
          </div>
          <div>        # enable additional event routes for forwarded
            requests</div>
          <div>        # - serial forking, RTP relaying handling, a.s.o.</div>
          <div>        if (is_method("INVITE|BYE|<wbr>SUBSCRIBE|UPDATE")) {</div>
          <div>                if(!t_is_set("branch_route")) {</div>
          <div>                        xlog("L_ALERT", "Its a Branch, go
            manage that !!!  <$ru>\n");</div>
          <div>                        t_on_branch("MANAGE_BRANCH");</div>
          <div>                }</div>
          <div>        }</div>
          <div>        if (is_method("INVITE|SUBSCRIBE|<wbr>UPDATE")) {</div>
          <div>                if(!t_is_set("onreply_route")) {</div>
          <div>                        xlog("L_ALERT", "its
            onreply_route, go manage !!!  <$ru>\n");</div>
          <div>                        t_on_reply("MANAGE_REPLY");</div>
          <div><br>
          </div>
          <div>                }</div>
          <div>        }</div>
          <div>        if (is_method("INVITE")) {</div>
          <div>                if(!t_is_set("failure_route")) {</div>
          <div>                        xlog("L_ALERT", "Its
            failure_route, go manage !!!  <$ru>\n");</div>
          <div>                        t_on_failure("MANAGE_FAILURE")<wbr>;</div>
          <div>                }</div>
          <div>        }</div>
          <div><br>
          </div>
          <div>        $fs = "udp:<a href="http://192.168.50.60:5060" target="_blank">192.168.50.60:5060</a>";</div>
          <div>        xlog("L_ALERT", "Trying to rely !!! 
            <$ru>\n");</div>
          <div>        if (!t_relay()) {</div>
          <div>                xlog("L_ALERT", "failed to rely !!! 
            <$ru>\n");</div>
          <div>                sl_reply_error();</div>
          <div>        }</div>
          <div>        exit;</div>
          <div>}</div>
        </div>
        <div><br>
        </div>
        <div>here is a part of the log:</div>
        <div><br>
        </div>
        <div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:
            WARNING: <core> [core/forward.c:231]:
            get_send_socket2(): <span style="background-color:rgb(255,255,0)">protocol/port
              mismatch (forced udp:<a href="http://192.168.50.60:5060" target="_blank">192.168.50.60:5060</a>, to ws:<a href="http://192.0.2.110:5060" target="_blank">192.0.2.110:5060</a>)</span></div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:
            DEBUG: <core> [core/msg_translator.c:424]:
            clen_builder(): content-length: 916 (916)</div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:
            WARNING: <core> [core/msg_translator.c:2765]:
            via_builder(): TCP/TLS connection (id: 0) for WebSocket
            could not be found</div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:
            ERROR: <core> [core/msg_translator.c:1980]:
            build_req_buf_from_sip_req(): could not create Via header</div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:
            ERROR: tm [t_fwd.c:476]: prepare_new_uac(): could not build
            request</div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:
            ERROR: tm [t_fwd.c:1735]: t_forward_nonack(): failure to add
            branches</div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:
            DEBUG: tm [t_funcs.c:334]: t_relay_to(): t_forward_nonack
            returned error -2 (-2)</div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:
            DEBUG: tm [t_funcs.c:352]: t_relay_to(): -2 error reply
            generation delayed</div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:
            ERROR: *** cfgtrace:request_route=[RELAY]
            c=[/etc/kamailio/kamailio.cfg] l=744 a=26 n=xlog</div>
          <div>Feb  9 22:48:48 incfskamtest01 /usr/sbin/kamailio[14896]:<span style="background-color:rgb(255,255,0)"> ALERT:
              <script>: failed to rely !!!  <<a href="mailto:sip%3A1001@192.0.2.110" target="_blank">sip:1001@192.0.2.110</a>;<wbr>transport=ws></span></div>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>is that because i set a $fu before t_relay() ?</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>any idea how to approach the issue ?</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset class="m_5960866116094684756mimeAttachmentHeader"></fieldset>
      <br>
      </div></div><pre>______________________________<wbr>_________________
Kamailio (SER) - Users Mailing List
<a class="m_5960866116094684756moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a>
<a class="m_5960866116094684756moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
    </font></span></blockquote><span class="HOEnZb"><font color="#888888">
    <br>
    <pre class="m_5960866116094684756moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="m_5960866116094684756moz-txt-link-abbreviated" href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a class="m_5960866116094684756moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - March 5-7, 2018, Berlin - <a class="m_5960866116094684756moz-txt-link-abbreviated" href="http://www.asipto.com" target="_blank">www.asipto.com</a>
Kamailio World Conference - May 14-16, 2018 - <a class="m_5960866116094684756moz-txt-link-abbreviated" href="http://www.kamailioworld.com" target="_blank">www.kamailioworld.com</a></pre>
  </font></span></div>

</blockquote></div><br></div>