<div dir="ltr">
<div dir="ltr"><div>Hi Bogdan!</div><div><br></div><div>Thanks for the answer! I tried this one:</div><div><br></div><div>#### TRACE module<br>loadmodule "tracer.so"<br>modparam("tracer", "trace_on", 1)<br>modparam("tracer", "trace_id","[tid]uri=mysql://XXXXX:XXXXXXX@localhost/opensips;table=sip_trace;")<br>modparam("tracer", "trace_id","[tid]uri=sip:<a href="http://172.16.34.91:5060">172.16.34.91:5060</a>")<br>modparam("tracer", "trace_local_ip", "172.16.34.91")<br></div><div><br></div><div>I use the constant string "tid" inside the trace(), no specific variable.<br></div><div><br></div><div>route{</div>        script_trace( 1, "$rm from $si, ruri=$ru, contact=$ct", "script_trace");<br>        #trace("tid", "d", "sip");<br>        #xlog("here_trace");<br><br>        #if (!has_totag()) {<br>        #       if(is_method("INVITE") ) {<br>        #       # We need to use the dialog module to have the outgoing ACK traced<br>        #       # trace("tid", "d", "sip");<br>        #}<br>        #}<br>        #else {<br>        #       match_dialog();<br>        #}<br><br>        #if (!is_method("INVITE,ACK,BYE,PRACK")) {<br>        # Requests that are not part of an established dialog will be transaction base traced<br>        #       trace("tid", "t", "sip");<br>        #       xlog("Message not in dialog - $rm\n");<br>        #}<br>        #trace("tid", "t", "sip");<br></div><div dir="ltr"></div><div dir="ltr">..</div><div dir="ltr"><br></div><div>BR, Pavel</div>

</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">вт, 11 окт. 2022 г. в 14:58, Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org">bogdan@opensips.org</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <font face="monospace">Hi PAvel,<br>
      <br>
      How do you define the tid you use for tracing ?<br>
      <br>
      Regards,<br>
    </font>
    <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank">https://www.opensips-solutions.com</a>
OpenSIPS Summit 27-30 Sept 2022, Athens
  <a href="https://www.opensips.org/events/Summit-2022Athens/" target="_blank">https://www.opensips.org/events/Summit-2022Athens/</a></pre>
    <div>On 9/21/22 7:45 PM, Pavel Ekshin wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>Hi Bogdan,</div>
        <div><br>
        </div>
        <div>Thanks for the answer.</div>
        <div>I tried this module, but nothing weird was found. On reply
          ACK messages in sngrep capture I see the correct "To/Contact''
          header, but in log the "To" header looks different, but it's
          not lead to any loop.</div>
        <div><br>
        </div>
        <div>
          Sep 20 16:51:55 openSIPS /usr/sbin/opensips[15619]: [Script
          Trace][/etc/opensips/opensips_residential.cfg:430][script_trace][core
          if] -> (INVITE from 172.18.53.131, ruri=<a href="http://sip:4002@172.16.34.173:5060" target="_blank">sip:4002@172.16.34.173:5060</a>,
          contact=<<a href="http://sip:opensips@172.18.53.131:5060" target="_blank">sip:opensips@172.18.53.131:5060</a>>)<br>
          Sep 20 16:51:55 openSIPS /usr/sbin/opensips[15619]: [Script
          Trace][/etc/opensips/opensips_residential.cfg:427][script_trace][module
          t_relay] -> (INVITE from 172.18.53.131, ruri=<a href="http://sip:4002@172.16.34.173:5060" target="_blank">sip:4002@172.16.34.173:5060</a>,
          contact=<<a href="http://sip:opensips@172.18.53.131:5060" target="_blank">sip:opensips@172.18.53.131:5060</a>>)<br>
          Sep 20 16:51:55 openSIPS /usr/sbin/opensips[15619]: [Script
          Trace][/etc/opensips/opensips_residential.cfg:430][script_trace][core
          exit] -> (INVITE from 172.18.53.131, ruri=<a href="http://sip:4002@172.16.34.173:5060" target="_blank">sip:4002@172.16.34.173:5060</a>,
          contact=<<a href="http://sip:opensips@172.18.53.131:5060" target="_blank">sip:opensips@172.18.53.131:5060</a>>)<br>
          Sep 20 16:51:55 openSIPS /usr/sbin/opensips[15619]: [Script
          Trace][/etc/opensips/opensips_residential.cfg:221][script_trace][core
          if] -> (ACK from 172.18.53.131,
          ruri=<a>sip:172.16.34.173:5060;transport=udp</a>, contact=<<a href="http://sip:opensips@172.18.53.131:5060" target="_blank">sip:opensips@172.18.53.131:5060</a>>)<br>
          Sep 20 16:51:55 openSIPS /usr/sbin/opensips[15619]: [Script
          Trace][/etc/opensips/opensips_residential.cfg:214][script_trace][module
          mf_process_maxfwd_header] -> (ACK from 172.18.53.131,
          ruri=<a>sip:172.16.34.173:5060;transport=udp</a>, contact=<<a href="http://sip:opensips@172.18.53.131:5060" target="_blank">sip:opensips@172.18.53.131:5060</a>>)<br>
          Sep 20 16:51:55 openSIPS /usr/sbin/opensips[15619]: [Script
          Trace][/etc/opensips/opensips_residential.cfg:258][script_trace][core
          if] -> (ACK from 172.18.53.131,
          ruri=<a>sip:172.16.34.173:5060;transport=udp</a>, contact=<<a href="http://sip:opensips@172.18.53.131:5060" target="_blank">sip:opensips@172.18.53.131:5060</a>>)<br>
          Sep 20 16:51:55 openSIPS /usr/sbin/opensips[15619]: [Script
          Trace][/etc/opensips/opensips_residential.cfg:221][script_trace][module
          has_totag] -> (ACK from 172.18.53.131,
          ruri=<a>sip:172.16.34.173:5060;transport=udp</a>, contact=<<a href="http://sip:opensips@172.18.53.131:5060" target="_blank">sip:opensips@172.18.53.131:5060</a>>)
        </div>
        <div><br>
        </div>
        <div>
          <div>________________________________________________________________________________________________________________________<br>
____________172.18.53.131:5060___________172.16.34.91:5060______________172.16.34.173:5060___________<a href="http://172.16.34.173:64087" target="_blank">172.16.34.173:64087</a><br>
__________qqqqqqqqqqwqqqqqqqqq__________qqqqqqqqqqwqqqqqqqqq__________qqqqqqqqqqwqqqqqqqqq__________qqqqqqqqqqwqqqqqqqqqx<br>
__16:06:48.772459___x________INVITE_(SDP)_________x_____________________________x_____________________________x_________<br>
________+0.001900___x_qqqqqqqqqqqqqqqqqqqqqqqqqq>_x_____________________________x_____________________________x_________<br>
__16:06:48.774359___x__407_Proxy_Authentication_R_x_____________________________x_____________________________x_________<br>
________+0.014197___x_<qqqqqqqqqqqqqqqqqqqqqqqqqq_x_____________________________x_____________________________x_________<br>
__16:06:48.788556___x_____________ACK_____________x_____________________________x_____________________________x________<br>
________+0.000103___x_qqqqqqqqqqqqqqqqqqqqqqqqqq>_x_____________________________x_____________________________x_________<br>
__16:06:48.788659___x________INVITE_(SDP)_________x_____________________________x_____________________________x_________<br>
________+0.005221___x_qqqqqqqqqqqqqqqqqqqqqqqqqq>_x_____________________________x_____________________________x_________<br>
__16:06:48.793880___x_____100_Giving_it_a_try_____x_____________________________x_____________________________x_________<br>
________+0.000664___x_<qqqqqqqqqqqqqqqqqqqqqqqqqq_x_____________________________x_____________________________x_________<br>
__16:06:48.794544___x_____________________________x________INVITE_(SDP)_________x_____________________________x_________<br>
________+0.004555___x_____________________________x_qqqqqqqqqqqqqqqqqqqqqqqqqq>_x_____________________________x_________<br>
__16:06:48.799099___x_____________________________x________________________100_Trying_________________________x_________<br>
________+0.039449___x_____________________________x_<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq_x_________<br>
__16:06:48.838548___x_____________________________x_______________________200_Ok_(SDP)________________________x_________<br>
________+0.000493___x_____________________________x_<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq_x_________<br>
__16:06:48.839041___x________200_Ok_(SDP)_________x_____________________________x_____________________________x_________<br>
________+0.012395___x_<qqqqqqqqqqqqqqqqqqqqqqqqqq_x_____________________________x_____________________________x_________<br>
__16:06:48.851436___x_____________ACK_____________x_____________________________x_____________________________x_________<br>
________+0.000488___x_qqqqqqqqqqqqqqqqqqqqqqqqqq>_x_____________________________x_____________________________x_________<br>
__16:06:48.851924___x_____________________________x_____________ACK_____________x_____________________________x_________<br>
________+8.768408___x_____________________________x_qqqqqqqqqqqqqqqqqqqqqqqqqq>_x_____________________________x_________<br>
__16:06:57.620332___x_____________BYE_____________x_____________________________x_____________________________x_________<br>
________+0.000966___x_qqqqqqqqqqqqqqqqqqqqqqqqqq>_x_____________________________x_____________________________x_________<br>
__16:06:57.621298___x_____________________________x_____________BYE_____________x_____________________________x_________<br>
________+0.003895___x_____________________________x_qqqqqqqqqqqqqqqqqqqqqqqqqq>_x_____________________________x________<br>
__16:06:57.625193___x_____________________________x__________________________200_Ok___________________________x_________<br>
________+0.000271___x_____________________________x_<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq_x_________<br>
__16:06:57.625464___x___________200_Ok____________x_____________________________x_____________________________x_________<br>
____________________x_<qqqqqqqqqqqqqqqqqqqqqqqqqq_x_____________________________x_____________________________x_________<br>
____________________x_____________________________x_____________________________x_____________________________x_________<br>
____________________x_____________________________x_____________________________x_____________________________x_________<br>
          </div>
          <div><br>
          </div>
        </div>
        If I disable trace("tid", "d/t/m", "sip") module at route level,
        I never faced with loop.I also found that trace("tid", "m",
        "sip") is worked for specific messages, f.e INVITE, and not
        looped too.<br>
        <div>If I have something wrong with the route, it should also be
          looped without enabled trace(), but it's not happen. I think
          it's around the rules of trace() module and rules there this
          module may be enabled. Maybe you have an example for enabling
          the trace() module globally?</div>
        <div><br>
        </div>
        <div>BR, Pavel</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">вт, 6 сент. 2022 г. в 11:53,
          Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org" target="_blank">bogdan@opensips.org</a>>:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi
          Pavel,<br>
          <br>
          The tracing part has nothing to do with the routing on the SIP
          side. And <br>
          usually you end up with SIP loops if, without changing the
          RURI, you <br>
          send the SIP request out, making OpenSIPS to send the request
          back to <br>
          itself (as the destination in RURI still points to OpenSIPS).<br>
          <br>
          I advice you to try to understand the execution flow via your
          script by <br>
          using the script_trace[1] function and logging the RURI (as
          $ru)<br>
          <br>
          [1] <br>
          <a href="https://www.opensips.org/Documentation/Script-CoreFunctions-3-2#script_trace" rel="noreferrer" target="_blank">https://www.opensips.org/Documentation/Script-CoreFunctions-3-2#script_trace</a><br>
          <br>
          Regards,<br>
          <br>
          Bogdan-Andrei Iancu<br>
          <br>
          OpenSIPS Founder and Developer<br>
             <a href="https://www.opensips-solutions.com" rel="noreferrer" target="_blank">https://www.opensips-solutions.com</a><br>
          OpenSIPS Summit 27-30 Sept 2022, Athens<br>
             <a href="https://www.opensips.org/events/Summit-2022Athens/" rel="noreferrer" target="_blank">https://www.opensips.org/events/Summit-2022Athens/</a><br>
          <br>
          On 8/30/22 9:31 PM, Pavel Ekshin wrote:<br>
          > Hi there,<br>
          > I try very basic scenario with tracing sip dialogs in
          OpenSIPS 3.2.7, <br>
          > and this scenario leads in an endless loop inside
          Opensips for SIP <br>
          > messages.<br>
          > Maybe someone is similarly affected or can point to the
          error on the <br>
          > route scenario? I use out of box residential
          configuration. I read the <br>
          > tracer module doc (<a href="https://opensips.org/docs/modules/devel/tracer.html" rel="noreferrer" target="_blank">https://opensips.org/docs/modules/devel/tracer.html</a>
          <br>
          > <<a href="https://opensips.org/docs/modules/devel/tracer.html" rel="noreferrer" target="_blank">https://opensips.org/docs/modules/devel/tracer.html</a>>),
          but dialog <br>
          > examples from doc also lead to loops.<br>
          > I also tried with transactions, but they are looped too.
          Trace for <br>
          > messages works fine.  I think I miss some points.<br>
          ><br>
          > MariaDB [opensips]> select method,COUNT(*) from
          sip_trace group by method;<br>
          > +--------+----------+<br>
          > | method | COUNT(*) |<br>
          > +--------+----------+<br>
          > | ACK    |     2625 |<br>
          > | BYE    |     2270 |<br>
          > | INVITE |      219 |<br>
          > +--------+----------+<br>
          ><br>
          > Below my config:<br>
          [...]<br>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div>