<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    <div class="moz-cite-prefix">On 07/03/15 00:27, Armen Babikyan
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAGDtNKDP87fV_5M56G7NjCrvp6h0Lfp-zpm7weCrHjLG93uA+w@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Daniel,
        <div><br>
        </div>
        <div>Thanks for the tip about disabling internal replies in the
          transaction module.</div>
        <div><br>
        </div>
        <div>About the new feature in usrloc - it looks like
          close_expired_tcp feature disconnects the connection if
          contacts on it expire.  I'm hoping to achieve the reverse,
          where I get to clean up when a connection closes abruptly.  To
          this end, for websockets, will Kamailio allow me to use
          uac_req_send() from within event_route[websocket:closed]?  I'm
          looking for a way to generate a de-REGISTER packet to send on
          to my registrar when a client abruptly closes their SIP/WS
          connection.  If not, do you have any suggestions to achieve
          something similar?</div>
      </div>
    </blockquote>
    <br>
    if you want to avoid attempting to send the sip message when there
    is no connection, then the option is to use set_forward_no_connect()
    before relaying.<br>
    <br>
 <a class="moz-txt-link-freetext" href="https://www.kamailio.org/wiki/cookbooks/4.2.x/core#set_forward_no_connect">https://www.kamailio.org/wiki/cookbooks/4.2.x/core#set_forward_no_connect</a><br>
    <br>
    Otherwise, look inside the usrloc module for the option to remove
    the record when the connection associated with it is no longer
    available (this is done on a timer check). Then you can get the
    event route executed for expired contact and there you can trigger
    something to trigger an un-register to the other server.<br>
    <br>
    uac_req_send() should work fine in event routes.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <br>
    <blockquote
cite="mid:CAGDtNKDP87fV_5M56G7NjCrvp6h0Lfp-zpm7weCrHjLG93uA+w@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Thanks again!</div>
        <div><br>
        </div>
        <div>Armen</div>
        <div><br>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, Mar 6, 2015 at 12:32 PM,
          Daniel-Constantin Mierla <span dir="ltr"><<a
              moz-do-not-send="true" 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">Hello,<br>
            <div>
              <div class="h5"><br>
                On 06/03/15 03:38, Armen Babikyan wrote:<br>
                > Hello,<br>
                ><br>
                > I am setting up this scenario using Kamailio 4.2.2:<br>
                ><br>
                > [UA] <-> [kamailio1] <-> [kamailio2]
                <-> [other stuff]<br>
                ><br>
                > UA connects to kamailio1 using SIP/WSS, kamailio1
                proxies request<br>
                > along to kamailio2.  Note that my intent here is to
                have kamailio2<br>
                > provide the registrar functionality.  The kamailio2
                (or something<br>
                > behind it) can also initiate transactions to UA,
                like OPTIONS, for<br>
                > example.<br>
                ><br>
                > I'm having an issue though: when the websocket
                connection between<br>
                > kamailio1 and UA dies, transaction requests from
                kamailio2 show up to<br>
                > kamailio1, and I get errors in kamailio1's logs
                because the WSS<br>
                > connection is gone.  I get messages as follows
                (debug=2):<br>
                ><br>
                > Mar  6 00:17:33 kamailio1
                /usr/local/sbin/kamailio[5653]: WARNING:<br>
                > <core> [msg_translator.c:2778]:
                via_builder(): TCP/TLS connection (id:<br>
                > 0) for WebSocket could not be found<br>
                > Mar  6 00:17:33 kamailio1
                /usr/local/sbin/kamailio[5653]: ERROR:<br>
                > <core> [msg_translator.c:1996]:
                build_req_buf_from_sip_req(): could<br>
                > not create Via header<br>
                > Mar  6 00:17:33 kamailio1
                /usr/local/sbin/kamailio[5653]: ERROR: tm<br>
                > [t_fwd.c:527]: prepare_new_uac(): could not build
                request<br>
                > Mar  6 00:17:33 kamailio1
                /usr/local/sbin/kamailio[5653]: ERROR: tm<br>
                > [t_fwd.c:1777]: t_forward_nonack(): ERROR:
                t_forward_nonack: failure<br>
                > to add branches<br>
                ><br>
                > At debug=4, I get the output here: <a
                  moz-do-not-send="true"
                  href="http://pastebin.com/d3RumekG" target="_blank">http://pastebin.com/d3RumekG</a><br>
                ><br>
                > In a running tshark, I see kamailio1 responding to
                kamailio2 with a<br>
                > "SIP/2.0 500 No error (2/TM)".  It appears to me
                that this is<br>
                > happening before t_relay() even returns.<br>
                ><br>
                > Is there a way to prevent the SIP 500 from being
                sent back to the<br>
                > client?  I am calling t_on_branch_failure("kam2bf")
                and<br>
                > t_on_failure("kam2f"), with each of those handlers<br>
                > (event_route[tm:branch-failure:kam2bf] and
                failure_route[kam2f])<br>
                > written to print a log message, but it appears that
                neither of those<br>
                > handlers are being called.  I tried installing
                these handlers<br>
                > independently to no avail.<br>
                ><br>
                > I also tried registering a t_on_reply() handler,
                thinking it was an<br>
                > internally-generated SIP response that might make
                it through my<br>
                > handler on its way out to kam2, but that is also
                not getting invoked.<br>
                ><br>
                > I want to return a 404 or something similar instead
                of having a 500<br>
                > auto-returned for me.<br>
                ><br>
                > Related to this, is there a way to query kamailio's
                in-memory client<br>
                > connectivity data structure for the connectivity
                status of a client?<br>
                > Or is this something best done by keeping track of
                every client myself<br>
                > using (e.g.) localcache?<br>
                ><br>
                > Any pointers are appreciated.  Thanks!<br>
                <br>
              </div>
            </div>
            If you want tm not to send an reply internally, see:<br>
            <br>
            -<br>
            <a moz-do-not-send="true"
href="http://kamailio.org/docs/modules/4.2.x/modules/tm.html#tm.f.t_set_disable_internal_reply"
              target="_blank">http://kamailio.org/docs/modules/4.2.x/modules/tm.html#tm.f.t_set_disable_internal_reply</a><br>
            <br>
            Also, you can list the details of tcp connections via tcp --
            see 'kamcmd<br>
            help' for the tcp related commands. Iirc, something similar
            should be<br>
            for websocket connections.<br>
            <br>
            The usrloc module keeps the id of the tcp connection for the
            client, the<br>
            development version (master branch) has the option to delete
            the record<br>
            if the connection is gone. For older versions there is also
            an option to<br>
            remove those records with some delay<br>
            (<a moz-do-not-send="true"
href="http://kamailio.org/docs/modules/4.2.x/modules/usrloc.html#usrloc.p.handle_lost_tcp"
              target="_blank">http://kamailio.org/docs/modules/4.2.x/modules/usrloc.html#usrloc.p.handle_lost_tcp</a>),<br>
            being a timer based cleanup.<br>
            <br>
            Cheers,<br>
            Daniel<br>
            <span class="HOEnZb"><font color="#888888"><br>
                --<br>
                Daniel-Constantin Mierla<br>
                <a moz-do-not-send="true"
                  href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a>
                - <a moz-do-not-send="true"
                  href="http://www.linkedin.com/in/miconda"
                  target="_blank">http://www.linkedin.com/in/miconda</a><br>
                Kamailio World Conference, May 27-29, 2015<br>
                Berlin, Germany - <a moz-do-not-send="true"
                  href="http://www.kamailioworld.com" target="_blank">http://www.kamailioworld.com</a><br>
                <br>
                <br>
                _______________________________________________<br>
                SIP Express Router (SER) and Kamailio (OpenSER) -
                sr-users mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
                <a moz-do-not-send="true"
                  href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users"
                  target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
              </font></span></blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a>
Kamailio World Conference, May 27-29, 2015
Berlin, Germany - <a class="moz-txt-link-freetext" href="http://www.kamailioworld.com">http://www.kamailioworld.com</a></pre>
  </body>
</html>