<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="monospace">Hi,<br>
      <br>
      yes, call it before ending the REQUEST route. I'm 100% the
      transaction is not deleted before the end of the route. And try to
      use the unix sock flavor for the function, not the fifo one.<br>
      <br>
      DO NOT use the sleep, you will block your whole opensips.<br>
      <br>
      Regards, <br>
    </font>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a class="moz-txt-link-freetext" href="https://www.opensips-solutions.com">https://www.opensips-solutions.com</a>
OpenSIPS Bootcamp 5-16 Dec 2022, online
  <a class="moz-txt-link-freetext" href="https://www.opensips.org/training/OpenSIPS_eBootcamp_2022/">https://www.opensips.org/training/OpenSIPS_eBootcamp_2022/</a></pre>
    <div class="moz-cite-prefix">On 10/17/22 11:56 AM, Ryzhik Ivan
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAG9R00phUydWncSvNdbs0+MRv6iL03ofAXfhOo4_AQbd3N0uDA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi, did you mean that i must call t_write_req once
        before <span
style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">REQUEST_ROUTE
          is finished? In this case the transaction was removed.</span>
        <div><span
            style="font-family:Helvetica,Arial;font-size:12px;text-align:justify">"</span><span
            style="font-family:monospace">even if you do not have to
            actually write anything to outer world - just fake it.</span><span
style="font-family:Helvetica,Arial;font-size:12px;text-align:justify">"
            - i must use fifo and i must read data from it, in else we
            got:<br>
          </span>ERROR:tm:write_to_fifo: nobody listening on
          [/tmp/moh.fifo] fifo for reading!<br>
          ERROR:tm:t_write_req: write_to_fifo failed<br>
        </div>
        <div>And last question is may I use sleep(20) at the end of
          route to keep transaction? or can i use modparam("tm",
          "wt_timer", 20)?</div>
        <div>Regards, Ivan</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">пн, 17 окт. 2022 г. в 09:38,
          Bogdan-Andrei Iancu <<a href="mailto:bogdan@opensips.org"
            moz-do-not-send="true">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 Ryzhik,<br>
              <br>
              Right, the transaction must be forced to stay until you
              are done with a final reply. Unfortunately there is no
              clear way to do this from script (this may be subject of
              further small improvements), but you can try taking
              advantage of the `t_write_req` [1] for this purpose, even
              if you do not have to actually write anything to outer
              world - just fake it.<br>
              <br>
              <br>
              [1] <a
href="https://opensips.org/html/docs/modules/3.2.x/tm.html#func_t_write_req"
                target="_blank" moz-do-not-send="true">https://opensips.org/html/docs/modules/3.2.x/tm.html#func_t_write_req</a><br>
              <br>
              Regards,<br>
            </font>
            <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank" moz-do-not-send="true">https://www.opensips-solutions.com</a>
OpenSIPS Summit 27-30 Sept 2022, Athens
  <a href="https://www.opensips.org/events/Summit-2022Athens/" target="_blank" moz-do-not-send="true">https://www.opensips.org/events/Summit-2022Athens/</a></pre>
            <div>On 10/13/22 2:45 PM, Ryzhik Ivan wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">Hi.
                <div>One more question.</div>
                <div>Everything works fine except the transaction was
                  deleted after 15 sec after the initial route was
                  finished.</div>
                <div>on INVITE i last do t_reply_with_body(183, "Session
                  progress", ...) and than exit;</div>
                <div><br>
                </div>
                <div>on end route log :</div>
                <div><br>
                </div>
                <div>2022-10-13T10:58:01.994598+00:00
                   DBG:tm:_reply_light: reply sent out.
                  buf=0x7f558a087d98: SIP/2.0 1...,
                  shmem=0x7f5549797470: SIP/2.0 1<br>
                  2022-10-13T10:58:01.994676+00:00  DBG:tm:_reply_light:
                  finished<br>
                </div>
                <div><br>
                </div>
                <div>2022-10-13T10:58:01.995835+00:00
                   DBG:tm:do_t_cleanup: transaction 0x7f5549793b18
                  already updated! Skipping update!<br>
                  2022-10-13T10:58:01.996020+00:00
                   DBG:tm:cleanup_uac_timers: RETR/FR timers reset<br>
                  2022-10-13T10:58:01.996202+00:00  <b>DBG:tm:insert_timer_unsafe:
                    [2]: 0x7f5549793b98 (12)</b><br>
                  2022-10-13T10:58:01.996317+00:00 <b> DBG:tm:t_unref:
                    UNREF_UNSAFE: [0x7f5549793b18] after is 0</b><br>
                  2022-10-13T10:58:01.996488+00:00
                   DBG:core:destroy_avp_list: destroying list (nil)<br>
                  2022-10-13T10:58:01.996673+00:00
                   DBG:core:receive_msg: cleaning up<br>
                  <br>
                  2022-10-13T10:58:07.651091+00:00<b>
                     DBG:tm:timer_routine: timer
                    routine:2,tl=0x7f5549793b98 next=(nil), timeout=12</b><br>
                  2022-10-13T10:58:07.651332+00:00  DBG:tm:wait_handler:
                  removing 0x7f5549793b18 from table<br>
                  2022-10-13T10:58:07.651425+00:00  DBG:tm:delete_ce<b>ll:
                    delete transaction 0x7f5549793b18</b><br>
                  2022-10-13T10:58:07.651513+00:00  DBG:tm:wait_handler:
                  done<br>
                  <br>
                </div>
                <div>Can you tell me how I can i fix this? Transaction
                  marked safe for deletion...</div>
                <div>Regards, Ivan</div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">ср, 12 окт. 2022 г. в
                  13:11, Bogdan-Andrei Iancu <<a
                    href="mailto:bogdan@opensips.org" target="_blank"
                    moz-do-not-send="true">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">Perfect !!!</font><br>
                    <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank" moz-do-not-send="true">https://www.opensips-solutions.com</a>
OpenSIPS Summit 27-30 Sept 2022, Athens
  <a href="https://www.opensips.org/events/Summit-2022Athens/" target="_blank" moz-do-not-send="true">https://www.opensips.org/events/Summit-2022Athens/</a></pre>
                    <div>On 10/12/22 1:09 PM, Ryzhik Ivan wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">I found a solution. hex strings are
                        reversed).
                        <div>Thank you very much!</div>
                      </div>
                      <br>
                      <div class="gmail_quote">
                        <div dir="ltr" class="gmail_attr">ср, 12 окт.
                          2022 г. в 12:59, Ryzhik Ivan <<a
                            href="mailto:ryzhik.ivan@gmail.com"
                            target="_blank" moz-do-not-send="true">ryzhik.ivan@gmail.com</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 dir="ltr">and one more research: $T_id
                            returns hex encoded label.hashid
                            <div>but my attempts failed:</div>
                            <div>got $T_id = 6545e285.3fe4</div>
                            <div>Send: {"jsonrpc": "2.0", "method":
                              "t_reply", "id": 1, "params": {"code":
                              "487", "reason": "Terminating",
                              "trans_id": "16356:1699078789", "to_tag":
                              "<null>"}}</div>
                            <div>Got:
                              b'{"jsonrpc":"2.0","error":{"code":404,"message":"Transaction
                              not found"},"id":1}'<br>
                              <br>
                            </div>
                          </div>
                          <br>
                          <div class="gmail_quote">
                            <div dir="ltr" class="gmail_attr">ср, 12
                              окт. 2022 г. в 11:13, Ryzhik Ivan <<a
                                href="mailto:ryzhik.ivan@gmail.com"
                                target="_blank" moz-do-not-send="true">ryzhik.ivan@gmail.com</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 dir="ltr">Thank you, Bogdan.
                                <div>I got stuck with tm documentation. </div>
                                <div>  1) MI t_reply command has named
                                  parameters, ok, no problem. </div>
                                <div>  2) trans_id - transaction
                                  identifier (has the hash_entry:label
                                  format)  - what is this? if i use
                                  $T_id i got reply "Invalid trans_id".</div>
                                <div>  3) Where can I get to_tag from
                                  script level on initial invite?</div>
                                <div>      ...</div>
                                <div>      t_reply_with_body(183,
                                  "Session progress",
                                  $(var(body){re.subst,$var(re)}) );<br>
                                        avp_db_query("insert into moh
                                  (callid, timeout, tid,totag) values
                                  ('$ci', $var(wait_time), '$T_id',
                                  '??????')"); <br>
                                        ...</div>
                                <div><br>
                                </div>
                                <div>Regards, Ivan.</div>
                              </div>
                              <br>
                              <div class="gmail_quote">
                                <div dir="ltr" class="gmail_attr">вт, 11
                                  окт. 2022 г. в 12:35, Bogdan-Andrei
                                  Iancu <<a
                                    href="mailto:bogdan@opensips.org"
                                    target="_blank"
                                    moz-do-not-send="true">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 Ivan,<br>
                                      <br>
                                      you can use timer_route, but as
                                      there is no way to send a reply
                                      for a particular transaction from
                                      script level (only to the
                                      currently processed request), you
                                      will have to trigger the MI cmds
                                      from the timer route, which is a
                                      bit hackish ....<br>
                                      <br>
                                      Regards,<br>
                                    </font>
                                    <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank" moz-do-not-send="true">https://www.opensips-solutions.com</a>
OpenSIPS Summit 27-30 Sept 2022, Athens
  <a href="https://www.opensips.org/events/Summit-2022Athens/" target="_blank" moz-do-not-send="true">https://www.opensips.org/events/Summit-2022Athens/</a></pre>
                                    <div>On 10/11/22 11:47 AM, Ryzhik
                                      Ivan wrote:<br>
                                    </div>
                                    <blockquote type="cite">
                                      <div dir="ltr">Hi, Bogdan!
                                        <div>What d' you think, can we
                                          use timer_route instead of an
                                          external script?</div>
                                        <div>Regards, Ivan.</div>
                                      </div>
                                      <br>
                                      <div class="gmail_quote">
                                        <div dir="ltr"
                                          class="gmail_attr">пн, 10 окт.
                                          2022 г. в 17:04, Bogdan-Andrei
                                          Iancu <<a
                                            href="mailto:bogdan@opensips.org"
                                            target="_blank"
                                            moz-do-not-send="true">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
                                              Ryzhik,<br>
                                              <br>
                                              Without a t_relay() it
                                              makes not much sense to
                                              have an dialog structure
                                              at all - the dialog module
                                              in opensips is actually
                                              design for proxied calls,
                                              not for UAC calls.<br>
                                              <br>
                                              IMO, you should keep it a
                                              transaction level, by
                                              sending replies back only.
                                              When getting the INVITE,
                                              put its call-id into a DB
                                              table (to keep only the
                                              "active" session) together
                                              with a lifetime /
                                              expiration time. When
                                              getting a CANCEL, update
                                              the table (set lifetime to
                                              0), to know it is
                                              terminated. And use an
                                              simple external script
                                              that keeps scanning the DB
                                              for (1) sending 487
                                              Terminated via MI if the
                                              record has 0 lifetime or
                                              (2) send a 408 Timeout via
                                              MI if the lifetime
                                              exceeded.<br>
                                              In a similar way you can
                                              handle the BYE - send back
                                              200OK for the BYE and set
                                              0 in lifetime, to send a
                                              487 canceled back <br>
                                              <br>
                                              Regards,<br>
                                            </font>
                                            <pre cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a href="https://www.opensips-solutions.com" target="_blank" moz-do-not-send="true">https://www.opensips-solutions.com</a>
OpenSIPS Summit 27-30 Sept 2022, Athens
  <a href="https://www.opensips.org/events/Summit-2022Athens/" target="_blank" moz-do-not-send="true">https://www.opensips.org/events/Summit-2022Athens/</a></pre>
                                            <div>On 10/10/22 4:33 PM,
                                              Ryzhik Ivan wrote:<br>
                                            </div>
                                            <blockquote type="cite">
                                              <div dir="ltr">Hello!
                                                <div>My opensips
                                                  version is 3.1 with
                                                  tm,dialog and
                                                  rtpengine modules.</div>
                                                <div>On incoming INVITE
                                                  i'm creating an early
                                                  dialog with 183
                                                  replies and i'm
                                                  playing audio to
                                                  caller with rtpengine,
                                                  no t_relay() on this
                                                  step, OS is acting as
                                                  UAS endpoint.<br>
                                                  If the caller cancels
                                                  the invite with a
                                                  CANCEL message - all
                                                  works great.<br>
                                                  But some users
                                                  terminate dialog with
                                                  BYE message.<br>
                                                  1) on BYE with to-tag
                                                  OS can't find dialog
                                                  with match_dialog(),
                                                  because to-tag
                                                  presents.<br>
                                                  2) if i use
                                                  load_dialog_ctx($ci) -
                                                   it is possible to
                                                  handle BYE.<br>
                                                  3) in early dialog
                                                  termination with BYE
                                                  we also need to send
                                                  final response to the
                                                  INVITE transaction. <br>
                                                  <br>
                                                  Maybe I did something
                                                  wrong, but I can't
                                                  handle the final
                                                  response to INVITE in
                                                  this case.<br>
                                                </div>
                                              </div>
                                              <br>
                                              <fieldset></fieldset>
                                              <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank" moz-do-not-send="true">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank" moz-do-not-send="true">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
                                            </blockquote>
                                            <br>
                                          </div>
                                        </blockquote>
                                      </div>
                                    </blockquote>
                                    <br>
                                  </div>
                                </blockquote>
                              </div>
                            </blockquote>
                          </div>
                        </blockquote>
                      </div>
                    </blockquote>
                    <br>
                  </div>
                </blockquote>
              </div>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>