<div dir="ltr">Hello Alexey. Yes, it is not usual SIP behaviour.<br>As I can see, for example, 3CX system can do this (separate option to authorize incoming REGISTER, INVITE and BYE requests).</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">ср, 10 авг. 2022 г. в 16:49, 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 Andrey,<br>
      <br>
      What you say is correct and unfortunately I have the trick here
      for you - indeed, the dialog structure is destroyed upon the first
      BYE (on its reply actually), so the second one will not match the
      dialog.... :-|<br>
      <br>
      Maybe we can have a feature request to actually have the dialog
      destroyed with a bit of a delay (similar to the transactions), but
      this is not so easy to implement.<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 8/10/22 3:57 PM, Andrey F wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>
          <div>Hello team!<br>
            Maybe anyone knows, is there a way to process a situation
            like this?<br>
            <br>
            <div>Scheme:<br>
              SIP Softphone A <-> OpenSIPS 3.1 <-> SIP
              Softphone B<br>
              <br>
            </div>
            <div>Steps:<br>
              1) SIP softphone B sent BYE request;</div>
            <div>2) SIP softphone A receives BYE and tried to authorize
              it (sent 401 response);</div>
            <div>3) SIP softphone B receives 401 and generates a new BYE
              with credentials;</div>
            <div>4) OpenSIPS did not pass second BYE request,
              because dialog was terminated on first BYE request.</div>
            <div><br>
            </div>
            <div>As far as I understand, SIP dialog on opensips is
              automatically destroyed after the first BYE was received.<br>
            </div>
            <div>From <a href="https://opensips.org/docs/modules/3.1.x/dialog.html" target="_blank">https://opensips.org/docs/modules/3.1.x/dialog.html</a>:<br>
            </div>
            <blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
              <div>
                <div style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:medium">
                  <div>
                    <div>
                      <h2 style="font-style:italic;border:1px solid rgb(176,176,176);background-color:rgb(236,236,236);padding-left:5px;font-size:14px;clear:both">1.2. How
                        it works</h2>
                    </div>
                  </div>
                </div>
              </div>
              <div><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">...<br>
                  The dialog is automatically destroyed when a</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify"> </span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">“BYE”</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify"> </span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">is
                  received. In case of no</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify"> </span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">“BYE”</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">,
                  the dialog lifetime is controlled via the default
                  timeout (see</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify"> </span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">“default_timeout”</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify"> </span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">-</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify"> </span><a href="https://opensips.org/docs/modules/3.1.x/dialog.html#param_default_timeout" title="1.6.5. default_timeout (integer)" style="color:rgb(4,31,197);font-family:Helvetica,Arial;font-size:12px;text-align:justify;text-decoration-line:none" target="_blank">default_timeout</a><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">)
                  and custom timeout (see</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify"> </span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">“$DLG_timeout”</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify"> </span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">-</span><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify"> </span><a href="https://opensips.org/docs/modules/3.1.x/dialog.html#pv_DLG_timeout" title="1.10.8. $DLG_timeout" style="color:rgb(4,31,197);font-family:Helvetica,Arial;font-size:12px;text-align:justify;text-decoration-line:none" target="_blank">$DLG_timeout</a><span style="color:rgb(0,0,0);font-family:Helvetica,Arial;font-size:12px;text-align:justify">).</span>  </div>
            </blockquote>
            <div><br>
              The second BYE witch credentials arrived to opensips very
              quickly (just a few ms).<br>
              <br>
              My problem is that second BYE can not pass these
              procedures:<br>
              1) <b>if (topology_hiding_match())</b><br>
            </div>
            <div>2)<b> if (t_check_trans())</b><br>
              <br>
              <br>
              On first BYE I see this in logs, it is matched.<br>
              1) <b>if (topology_hiding_match()) logs:<br>
              </b></div>
            <blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
              <div>DBG:dialog:api_match_dialog: We found DID param in
                R-URI with value of XXXXXXXXX</div>
              <div>DBG:dialog:dlg_onroute: route param is 'XXXXXXXXX'
                (len=12)</div>
              <div>DBG:dialog:lookup_dlg: dialog id=1424242860 found on
                entry 3032</div>
              <div>DBG:core:parse_headers: flags=58</div>
              <div>DBG:core:parse_to_param: tag=YYYYYYY</div>
              <div>DBG:core:parse_to_param: end of header reached,
                state=11</div>
              <div>DBG:core:_parse_to: end of header reached, state=29</div>
              <div>DBG:core:_parse_to: display={}, ruri={<a href="http://sip:1@1.1.1.1:1/" target="_blank">sip:1@1.1.1.1:1</a>}</div>
              <div>DBG:dialog:next_state_dlg: dialog 0x7f16b2b95cf8
                changed from state 4 to state 5, due event 7</div>
              <div>DBG:dialog:init_dlg_term_reason: Setting DLG term
                reason to [Upstream BYE]</div>
            </blockquote>
            <div><br>
            </div>
            <div>On second BYE I see this in logs, it is not matched.<br>
              2) <b>if (topology_hiding_match()) logs: </b>Dialog can
              not be matched<br>
            </div>
            <blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
              <div>DBG:dialog:api_match_dialog: We found DID param in
                R-URI with value of XXXXXXXXX</div>
              <div>DBG:dialog:dlg_onroute: route param is 'XXXXXXXXX'
                (len=12)</div>
              <div>DBG:dialog:lookup_dlg: no dialog id=1424242860 found
                on entry 3032</div>
              <div>DBG:dialog:dlg_onroute: unable to find dialog for BYE
                with route param 'XXXXXXXXX'</div>
              <div>DBG:core:parse_headers: flags=58</div>
              <div>DBG:core:parse_to_param: tag=TTTTTT</div>
              <div>DBG:core:parse_to_param: end of header reached,
                state=11</div>
              <div>DBG:core:_parse_to: end of header reached, state=29</div>
              <div>DBG:core:_parse_to: display={}, ruri={<a href="http://sip:1@1.1.1.1:1/" target="_blank">sip:1@1.1.1.1:1</a>}</div>
              <div>DBG:dialog:get_dlg: input ci=<CCCCCCCCCCC>(37),
                tt=<TTTTTT>(15), ft=<FFFFFFFFF>(14)</div>
              <div>DBG:dialog:get_dlg: no dialog callid='CCCCCCCCCCC'
                found</div>
              <div>DBG:dialog:dlg_onroute: Callid 'CCCCCCCCCCC' not
                found</div>
            </blockquote>
            <div><b><br>
              </b></div>
            <div>3)<b> if (t_check_trans()) </b><b>logs:</b><b> </b>transaction
              can not be matched</div>
            <blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
              <div>DBG:core:parse_headers: flags=78</div>
              <div>DBG:tm:t_lookup_request: start searching: hash=44043,
                isACK=0</div>
              <div>DBG:tm:matching_3261: RFC3261 transaction matching
                failed</div>
              <div>DBG:tm:t_lookup_request: no transaction found</div>
              <div>DBG:core:parse_headers: flags=ffffffffffffffff</div>
            </blockquote>
          </div>
          <div><br>
          </div>
          <div>Finally, maybe anyone knows how to resolve this problem?</div>
          <div>Thank you!</div>
        </div>
        <div><br>
        </div>
        <div><span style="color:rgb(136,136,136)">--</span><br style="color:rgb(136,136,136)">
          <div dir="ltr" style="color:rgb(136,136,136)">
            <div dir="ltr">
              <div style="color:rgb(34,34,34)">Best regards, </div>
              <font color="#888888">
                <div style="color:rgb(34,34,34)">Andrey F</div>
              </font></div>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div>

</blockquote></div>