<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello,</p>
    <p>can you try the TOH header scenario with any of latest 5.4, 5.5
      or master branches? I just pushed a commit that should fix it.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 05.05.21 18:32, Ilie Soltanici
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAJQ6-U2=vXS3D=3xddUOLeaSxvQ+i+UrCQDay0SQwGvto-qivg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hello,
        <div><br>
        </div>
        <div>Thank you Daniel for looking into this, I think I found the
          problem and it was in the header:</div>
        <div><br>
        </div>
        <div><b>TOH: 123456789</b><br>
        </div>
        <div><b><br>
          </b></div>
        <div>For some reason kamailio parsed it as a "To" header, by
          removing this header the Cancel message was delivered
          successfully out.</div>
        <div><br>
        </div>
        <div>Thank you.</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, 5 May 2021 at 17:28,
          Daniel-Constantin Mierla <<a
            href="mailto:miconda@gmail.com" moz-do-not-send="true">miconda@gmail.com</a>>
          wrote:<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>
            <p>Hello,</p>
            <p>hmm, 5.4.5 should have been also good, being the last in
              5.4.x series, with the fix that I was thinking of. I will
              look at the code.</p>
            <p>Cheers,<br>
              Daniel<br>
            </p>
            <div>On 05.05.21 17:56, Ilie Soltanici wrote:<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">Hello,
                <div><br>
                </div>
                <div>Yes, initially I was trying with version 5.4.5,
                  then I upgraded to the latest version from 5.5 branch
                  - but this didn't fix the issue.</div>
                <div><br>
                </div>
                <div>version: kamailio 5.5.0 (x86_64/linux) d4c1a1<br>
                  flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS,
                  USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK,
                  SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC,
                  DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT,
                  USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR,
                  USE_DST_BLOCKLIST, HAVE_RESOLV_RES,
                  TLS_PTHREAD_MUTEX_SHARED<br>
                  ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144,
                  MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE
                  8MB<br>
                  poll method support: poll, epoll_lt, epoll_et,
                  sigio_rt, select.<br>
                  id: d4c1a1 <br>
                  compiled on 16:08:42 May  5 2021 with gcc 8.3.0<br>
                </div>
                <div><br>
                </div>
                <div>OS: Description: Debian GNU/Linux 10 (buster)</div>
                <div><br>
                </div>
                <div>Thank you.</div>
              </div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Wed, 5 May 2021 at
                  16:42, Daniel-Constantin Mierla <<a
                    href="mailto:miconda@gmail.com" target="_blank"
                    moz-do-not-send="true">miconda@gmail.com</a>>
                  wrote:<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>
                    <p>Hello,</p>
                    <p>are you running the latest version in the X.Y
                      series? Likely you have a version with an issue
                      that was fixed, iirc.</p>
                    <p>Cheers,<br>
                      Daniel<br>
                    </p>
                    <div>On 05.05.21 17:32, Ilie Soltanici wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">Hello,
                        <div><br>
                        </div>
                        <div>No, that's not the case, see below the
                          INVITE sent to the branch:</div>
                        <div><br>
                        </div>
                        <div>INVITE <a moz-do-not-send="true">sip:123456789@1.2.3.4:5060;transport=UDP</a>
                          SIP/2.0<br>
                          Record-Route: <a moz-do-not-send="true"><sip:1.2.3.4:5060;lr;ftag=244c2803;did=cb4.8cb></a><br>
                          Via: SIP/2.0/UDP
                          1.2.3.4:5060;branch=z9hG4bK0f41.5079ae8da835958ee58ca1e8a4eb057b.0<br>
                          Via: SIP/2.0/UDP
192.168.1.10:40769;received=1.3.5.7;branch=z9hG4bK-524287-1---46a5782b47b6ec85;rport=40769<br>
                          Max-Forwards: 69<br>
                          Contact: <a moz-do-not-send="true"><sip:101@1.3.5.7:40769;transport=UDP;alias=1.3.5.7~40769~1></a><br>
                          To: <<a
                            href="http://sip:123456789@1.2.3.4:5060"
                            target="_blank" moz-do-not-send="true">sip:123456789@1.2.3.4:5060</a>><br>
                          From: <a moz-do-not-send="true"><sip:101@1.2.3.4:5060;transport=UDP></a>;tag=244c2803<br>
                          Call-ID: KfuC1GMvCvk1YCSKnHwDrw..<br>
                          CSeq: 2 INVITE<br>
                          Allow: INVITE, ACK, CANCEL, BYE, NOTIFY,
                          REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE<br>
                          Content-Type: application/sdp<br>
                          User-Agent: Z 5.4.12 v2.10.13.2-mod<br>
                          Allow-Events: presence, kpml, talk<br>
                          Content-Length: 336<br>
                          TOH: 123456789<br>
                          <br>
                          v=0<br>
                          o=Z 1620220570589 1 IN IP4 1.3.5.7<br>
                          s=Z<br>
                          c=IN IP4 1.3.5.7<br>
                          t=0 0<br>
                          m=audio 8000 RTP/AVP 106 9 98 101 0 8 3<br>
                          a=rtpmap:106 opus/48000/2<br>
                          a=fmtp:106 sprop-maxcapturerate=16000;
                          minptime=20; useinbandfec=1<br>
                          a=rtpmap:98 telephone-event/48000<br>
                          a=fmtp:98 0-16<br>
                          a=rtpmap:101 telephone-event/8000<br>
                          a=fmtp:101 0-16<br>
                          a=sendrecv<br>
                        </div>
                        <div><br>
                        </div>
                        <div>thanks</div>
                      </div>
                      <br>
                      <div class="gmail_quote">
                        <div dir="ltr" class="gmail_attr">On Wed, 5 May
                          2021 at 16:24, Daniel-Constantin Mierla <<a
                            href="mailto:miconda@gmail.com"
                            target="_blank" moz-do-not-send="true">miconda@gmail.com</a>>
                          wrote:<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>
                            <p>Hello,</p>
                            <p>the CANCEL to be sent is generated
                              locally by tm module from the INVITE that
                              was sent on the branch, so the errors is
                              actually about a duplicate To header in
                              that INVITE. Check it on the network to
                              see if that's the case.<br>
                            </p>
                            <p>Cheers,<br>
                              Daniel<br>
                            </p>
                            <div>On 05.05.21 16:25, Ilie Soltanici
                              wrote:<br>
                            </div>
                            <blockquote type="cite">
                              <div dir="ltr">Hello,<br>
                                <div><br>
                                </div>
                                <div>We are having an issue here where
                                  Kamailio is complaining about
                                  duplicate To header, while in the SIP
                                  Packet there is just one. See below
                                  the log message:</div>
                                <div><br>
                                </div>
                                <div>DEBUG: tm [t_msgbuilder.c:391]:
                                  build_local_reparse(): duplicate To
                                  header</div>
                                <div>ERROR: tm [t_msgbuilder.c:531]:
                                  build_local_reparse(): cannot build
                                  CANCEL request<br>
                                  ERROR: tm [t_cancel.c:297]:
                                  cancel_branch(): attempt to build a
                                  CANCEL failed<br>
                                  ERROR: tm [t_fwd.c:1434]:
                                  e2e_cancel(): cancel error<br>
                                </div>
                                <div><br>
                                </div>
                                <div>And this is the sip message:</div>
                                <div><br>
                                </div>
                                <div>CANCEL <a
                                    href="http://sip:123456789@1.2.3.4:5060"
                                    target="_blank"
                                    moz-do-not-send="true">sip:123456789@1.2.3.4:5060</a>
                                  SIP/2.0<br>
                                  Via: SIP/2.0/UDP
                                  192.168.1.1:19373;branch=z9hG4bK-524287-1---7774073fad1a3264;rport<br>
                                  Max-Forwards: 70<br>
                                  To: <<a
                                    href="http://sip:123456789@1.2.3.4:5060"
                                    target="_blank"
                                    moz-do-not-send="true">sip:123456789@1.2.3.4:5060</a>><br>
                                  From: "101"<<a
                                    href="http://sip:101@1.2.3.4:5060"
                                    target="_blank"
                                    moz-do-not-send="true">sip:101@1.2.3.4:5060</a>>;tag=6f373b66<br>
                                  Call-ID: hC2O6zx8ZaUJ1di046<br>
                                  CSeq: 2 CANCEL<br>
                                  Proxy-Authorization: Digest
username="101",realm="1.2.3.4",nonce="YJKbfWCSmlFTHxdJfKmySydF9L7FzfaqcgyOo4A=",uri="<a
href="http://sip:123456789@1.2.3.4:5060" target="_blank"
                                    moz-do-not-send="true">sip:123456789@1.2.3.4:5060</a>",response="2bf2ba8ef2374d6aa8c39d650613077d",algorithm=MD5<br>
                                  User-Agent: TEST<br>
                                  Content-Length: 0<br>
                                </div>
                                <div><br>
                                </div>
                                <div>version: kamailio 5.5.0
                                  (x86_64/linux) d4c1a1</div>
                                <div><br>
                                </div>
                                <div>The route itself, is like in the
                                  standard documentation:</div>
                                <div><br>
                                </div>
                                <div># CANCEL processing<br>
                                            if KSR.is_CANCEL() :<br>
                                                KSR.info(RANDOM_LOG +
                                  'KSR.is_CANCEL')<br>
                                                if
                                  KSR.tm.t_check_trans()>0 :<br>
                                                   
                                  self.ksr_route_relay(msg)<br>
                                                return 1<br>
                                </div>
                                <div><br>
                                </div>
                                <div><br>
                                </div>
                                <div>   def ksr_route_relay(self, msg):<br>
                                          if KSR.is_method_in("IBSU") :<br>
                                              if
                                  KSR.tm.t_is_set("branch_route")<0 :<br>
                                                 
                                  KSR.tm.t_on_branch("ksr_branch_manage")<br>
                                  <br>
                                          if KSR.is_method_in("ISU") :<br>
                                              if
                                  KSR.tm.t_is_set("onreply_route")<0
                                  :<br>
                                                 
                                  KSR.tm.t_on_reply("ksr_onreply_manage")<br>
                                  <br>
                                          if KSR.is_INVITE() :<br>
                                              if
                                  KSR.tm.t_is_set("failure_route")<0
                                  :<br>
                                                 
                                  KSR.tm.t_on_failure("ksr_failure_manage")<br>
                                  <br>
                                          if KSR.tm.t_relay()<0 :<br>
                                              KSR.sl.sl_reply_error()<br>
                                  <br>
                                          return -255<br>
                                </div>
                                <div><br>
                                </div>
                                <div>Thanks</div>
                              </div>
                              <br>
                              <fieldset></fieldset>
                              <pre>__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions
  * <a href="mailto:sr-users@lists.kamailio.org" target="_blank" moz-do-not-send="true">sr-users@lists.kamailio.org</a>
Important: keep the mailing list in the recipients, do not reply only to the sender!
Edit mailing list options or unsubscribe:
  * <a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank" moz-do-not-send="true">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
                            </blockquote>
                            <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank" moz-do-not-send="true">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank" moz-do-not-send="true">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank" moz-do-not-send="true">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Online
May 17-20, 2021 (Europe Timezone) - June 7-10, 2021 (America Timezone)
  * <a href="https://www.asipto.com/sw/kamailio-advanced-training-online/" target="_blank" moz-do-not-send="true">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
                          </div>
                        </blockquote>
                      </div>
                    </blockquote>
                    <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank" moz-do-not-send="true">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank" moz-do-not-send="true">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank" moz-do-not-send="true">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Online
May 17-20, 2021 (Europe Timezone) - June 7-10, 2021 (America Timezone)
  * <a href="https://www.asipto.com/sw/kamailio-advanced-training-online/" target="_blank" moz-do-not-send="true">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
                  </div>
                </blockquote>
              </div>
            </blockquote>
            <pre cols="72">-- 
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank" moz-do-not-send="true">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank" moz-do-not-send="true">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank" moz-do-not-send="true">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Online
May 17-20, 2021 (Europe Timezone) - June 7-10, 2021 (America Timezone)
  * <a href="https://www.asipto.com/sw/kamailio-advanced-training-online/" target="_blank" moz-do-not-send="true">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<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 - Online
May 17-20, 2021 (Europe Timezone) - June 7-10, 2021 (America Timezone)
  * <a class="moz-txt-link-freetext" href="https://www.asipto.com/sw/kamailio-advanced-training-online/">https://www.asipto.com/sw/kamailio-advanced-training-online/</a></pre>
  </body>
</html>