<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body 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="moz-txt-link-freetext" href="https://www.kamailio.org/docs/modules/stable/modules/path.html#path.p.enable_r2">https://www.kamailio.org/docs/modules/stable/modules/path.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>
    <br>
    <div class="moz-cite-prefix">On 09.02.18 22:57, Tihomir Culjaga
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAJoKKdVhVoAT+ZPpO-XXNV5B+fTaJAJx24dYOZe6W1vaRqoemw@mail.gmail.com">
      <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> 
 ------------------------------------------------------------------------</div>
          <div>   REGISTER <a class="moz-txt-link-freetext" href="sip:192.168.50.60">sip:192.168.50.60</a> SIP/2.0</div>
          <div>   Via: SIP/2.0/UDP
            192.168.50.60;branch=z9hG4bKa929.0f66d60c4333f4a3a9d83d41a63295d9.0</div>
          <div>   Via: SIP/2.0/WSS
            192.0.2.110;rport=63296;received=192.168.200.77;branch=z9hG4bK6931435</div>
          <div>   Max-Forwards: 69</div>
          <div>   To: <<a href="mailto:sip%3A1001@192.168.50.60"
              moz-do-not-send="true">sip:1001@192.168.50.60</a>></div>
          <div>   From: <<a href="mailto:sip%3A1001@192.168.50.60"
              moz-do-not-send="true">sip:1001@192.168.50.60</a>>;tag=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-b6d6-419b0a34ee90",
            uri=<a class="moz-txt-link-rfc2396E" href="sip:192.168.50.60">"sip:192.168.50.60"</a>,
            response="9b592b874474d4ffe5769f2410baceef", qop=auth,
            cnonce="sf7ff0fp8tm5", nc=00000001</div>
          <div>   Contact: <<a href="mailto:sip%3A1001@192.0.2.110"
              moz-do-not-send="true">sip:1001@192.0.2.110</a>;transport=ws>;reg-id=1;+sip.instance="<urn:uuid:587f4694-7e55-46dc-a858-579a82556a20>";expires=600</div>
          <div>   Allow:
            ACK,CANCEL,INVITE,MESSAGE,BYE,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="moz-txt-link-rfc2396E" href="sip:192.168.50.60;lr;received=192.168.200.77~63296~6"><sip:192.168.50.60;lr;received=192.168.200.77~63296~6></a></div>
          <div>   </div>
          <div> 
 ------------------------------------------------------------------------</div>
          <div>send 719 bytes to udp/[192.168.50.60]:5060 at
            22:38:07.329444:</div>
          <div> 
 ------------------------------------------------------------------------</div>
          <div>   SIP/2.0 200 OK</div>
          <div>   Via: SIP/2.0/UDP
            192.168.50.60;branch=z9hG4bKa929.0f66d60c4333f4a3a9d83d41a63295d9.0</div>
          <div>   Via: SIP/2.0/WSS
            192.0.2.110;rport=63296;received=192.168.200.77;branch=z9hG4bK6931435</div>
          <div>   From: <<a href="mailto:sip%3A1001@192.168.50.60"
              moz-do-not-send="true">sip:1001@192.168.50.60</a>>;tag=vq30modpgd</div>
          <div>   To: <<a href="mailto:sip%3A1001@192.168.50.60"
              moz-do-not-send="true">sip:1001@192.168.50.60</a>>;tag=Spya88DKU9gSQ</div>
          <div>   Call-ID: dlnrna9o4ngn25fb9d1vi2</div>
          <div>   CSeq: 196 REGISTER</div>
          <div>   Contact: <<a href="mailto:sip%3A1001@192.0.2.110"
              moz-do-not-send="true">sip:1001@192.0.2.110</a>;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+git~20171120T163416Z~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="moz-txt-link-rfc2396E" href="sip:192.168.50.60"><sip:192.168.50.60></a>;lr;received=192.168.200.77~63296~6</div>
          <div>   Content-Length: 0</div>
          <div>   </div>
          <div> 
 ------------------------------------------------------------------------</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> 
 ------------------------------------------------------------------------</div>
          <div>   INVITE <a href="mailto:sip%3A1001@192.0.2.110"
              moz-do-not-send="true">sip:1001@192.0.2.110</a>;transport=ws
            SIP/2.0</div>
          <div>   Via: SIP/2.0/UDP
            192.168.50.65:15060;rport;branch=z9hG4bKXHcX316pDgXZB</div>
          <div>   Route:
            <a class="moz-txt-link-rfc2396E" href="sip:192.168.50.60"><sip:192.168.50.60></a>;lr;received=192.168.200.77~63296~6</div>
          <div>   Max-Forwards: 70</div>
          <div>   From: "" <<a href="mailto:sip%3A1002@192.168.50.65"
              moz-do-not-send="true">sip:1002@192.168.50.65</a>>;tag=tZQ393yprj7BK</div>
          <div>   To: <<a href="mailto:sip%3A1001@192.0.2.110"
              moz-do-not-send="true">sip:1001@192.0.2.110</a>;transport=ws></div>
          <div>   Call-ID: 8212b700-8885-1236-08b3-000c293ae94e</div>
          <div>   CSeq: 118770326 INVITE</div>
          <div>   Contact: <<a
              href="http://sip:mod_sofia@192.168.50.65:15060"
              moz-do-not-send="true">sip:mod_sofia@192.168.50.65:15060</a>></div>
          <div>   User-Agent:
            FreeSWITCH-mod_sofia/1.6.19+git~20171120T163416Z~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"
              moz-do-not-send="true">sip:1002@192.168.50.65</a>>;party=calling;screen=yes;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|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|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");</div>
          <div>                }</div>
          <div>        }</div>
          <div><br>
          </div>
          <div>        $fs = "udp:<a href="http://192.168.50.60:5060"
              moz-do-not-send="true">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"
                moz-do-not-send="true">192.168.50.60:5060</a>, to ws:<a
                href="http://192.0.2.110:5060" moz-do-not-send="true">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"
                moz-do-not-send="true">sip:1001@192.0.2.110</a>;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="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - March 5-7, 2018, Berlin - <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
Kamailio World Conference - May 14-16, 2018 - <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
  </body>
</html>