<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">Hope everyone is well, and looking forward to seeing you all whenever Kamailio World ends up being!</div><div class=""><br class=""></div><div class="">I’m currently dealing with an issue which I’m unsure if it’s due to my own implementation, or a bug.</div><div class=""><br class=""></div><div class="">When attempting to manipulate the Contact header via app_ruby, the SIP message I send ends up being malformed. Here’s the code I’m using:</div><div class=""><br class=""></div><div class=""><div style="color: rgb(212, 212, 212); background-color: rgb(30, 30, 30); font-family: Menlo, Monaco, "Courier New", monospace; line-height: 18px; white-space: pre;" class=""><div class=""><span style="color: #c586c0;" class="">def</span> <span style="color: #dcdcaa;" class="">replace_contact_header</span>(<span style="color: #9cdcfe;" class="">uri</span>)</div><div class="">  <span style="color: #6a9955;" class="">#KSR::HDR.remove("Contact") if KSR::HDR.is_present('Contact') > 0</span></div><div class="">  <span style="color: #6a9955;" class="">#KSR::HDR.append("Contact: #{uri}\r\n")  </span></div><div class="">  <span style="color: #4ec9b0;" class="">KSR</span>::<span style="color: #4ec9b0;" class="">HDR</span>.rmappend(<span style="color: #ce9178;" class="">"Contact"</span>, <span style="color: #ce9178;" class="">"Contact: </span><span style="color: #569cd6;" class="">#{</span>uri<span style="color: #569cd6;" class="">}</span><span style="color: #d7ba7d;" class="">\r\n</span><span style="color: #ce9178;" class="">"</span>)</div><div class=""><span style="color: #c586c0;" class="">end</span></div></div></div><div class=""><br class=""></div><div class="">Note that I have tried both rmappend and the commented out functions too. I call this with a custom built URI, such as <<a href="mailto:61400123123@kamailio.test.uconnected.com.au" class="">61400123123@kamailio.test.uconnected.com.au</a>>. This function is called just before a KSR::TM.t_relay(). Here’s the result I get watching from tshark (some info scrubbed for privacy):</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" size="1" class="">Record-Route: <<a href="sip:1.2.3.4;lr;ftag=e3p42efd3635HH;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVFHDQAAs83AEGwAAFgwCQA8QY3RlZC5jb20uYXU-;did=927.f0f2" class="">sip:1.2.3.4;lr;ftag=e3p42efd3635HH;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVFHDQAAs83AEGwAAFgwCQA8QY3RlZC5jb20uYXU-;did=927.f0f2</a>></font></div><div class=""><font face="Courier New" size="1" class="">…</font></div><div class=""><font face="Courier New" size="1" class="">Call-ID: 3de29646-e423-1238-e712-023563fb337c</font></div><div class=""><font face="Courier New" size="1" class="">CSeq: 17736747 INVITE</font></div><div class=""><font face="Courier New" size="1" class=""><a href="sip:4.5.6.7:5060;alias=10.100.1.1~5060~1Content-Type:" class="">sip:4.5.6.7:5060;alias=10.100.1.1~5060~1Content-Type:</a> application/sdp</font></div><div class=""><font face="Courier New" size="1" class="">Content-Length: 483</font></div><div class=""><font face="Courier New" size="1" class="">Contact: <<a href="sip:61400123123@kamailio.test.uconnected.com.au" class="">sip:61400123123@kamailio.test.uconnected.com.au</a>></font></div><div class=""><br class=""></div></div><div class="">In this case, 4.5.6.7 is the PBX I made the call from (and the value of the original Contact header), and 1.2.3.4 is what <a href="http://kamailio.test.uconnected.com.au" class="">kamailio.test.uconnected.com.au</a> resolves to, and is this Kamailio instance.</div><div class=""><br class=""></div><div class="">Here’s a copy of the same thing when I don’t call my replace_contact_header function and t_relay:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" size="1" class="">Record-Route: <<a href="sip:1.2.3.4;lr;ftag=j6jebCSa5Qap6c;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVND38dTgwEGEAEGwAAFgwCQA8Fdn83lZC5jb20uYXU-;did=827.40b" class="">sip:1.2.3.4;lr;ftag=j6jebCSa5Qap6c;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVND38dTgwEGEAEGwAAFgwCQA8Fdn83lZC5jb20uYXU-;did=827.40b</a>></font></div><div class=""><font face="Courier New" size="1" class="">...</font></div><div class=""><font face="Courier New" size="1" class="">Call-ID: 249571c5-e91a-ae91-6d8e-023563fb337c</font></div><div class=""><font face="Courier New" size="1" class="">CSeq: 17735867 INVITE</font></div><div class=""><font face="Courier New" size="1" class="">Contact: <<a href="sip:4.5.6.7:5060;alias=10.100.1.1~5060~1" class="">sip:4.5.6.7:5060;alias=10.100.1.1~5060~1</a>></font></div><div class=""><font face="Courier New" size="1" class="">Content-Type: application/sdp</font></div><div class=""><font face="Courier New" size="1" class="">Content-Length: 483</font></div><div class=""><br class=""></div></div><div class="">Given the relative simplicity of the function, I have to assume this is an error with how the function is manipulating the existing Contact header? It seems that the “Contact: <“ part of the header is being removed as well as the “>\r\n", but the rest being left.</div><div class=""><br class=""></div><div class="">I’m currently using commit <a href="https://github.com/kamailio/kamailio/commit/283e46" class="">283e468401d809ca9b71368c32badf3a70d48b8b</a> on Amazon Linux 2, which is CentOS/RHEL based.</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">Andrew</div></body></html>