<div dir="ltr">You're using set_contact_alias(), which already changes the Contact header. Try msg_apply_changes() before your 2nd Contact header change.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 19, 2020 at 5:11 AM Sergey Safarov <<a href="mailto:s.safarov@gmail.com">s.safarov@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 dir="ltr">Looks as not expected here<br><br><div><font color="#0000ff">sip:4.5.6.7:5060;alias=10.100.1.1~5060~1Content-Type: application/sdp<br></font></div><div><br></div><div>About contact header.<br>Yes it is really important header.</div><div>If your carrier want specific Contact header format, then I recommend try use other provider.</div><div><br></div><div>Contact header used also for RURI headers. So you cannot simple change Contact.</div><div><br></div><div>Kamailio is very good SP proxy. For you will more simple invite Kamailio tech guy to configure inter-working with this specific carrier.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 19, 2020 at 4:43 AM Andrew White <<a href="mailto:andrew@uconnected.com.au" target="_blank">andrew@uconnected.com.au</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>Hi all,<div><br></div><div>Hope everyone is well, and looking forward to seeing you all whenever Kamailio World ends up being!</div><div><br></div><div>I’m currently dealing with an issue which I’m unsure if it’s due to my own implementation, or a bug.</div><div><br></div><div>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><br></div><div><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-wrap"><div><span style="color:rgb(197,134,192)">def</span> <span style="color:rgb(220,220,170)">replace_contact_header</span>(<span style="color:rgb(156,220,254)">uri</span>)</div><div>  <span style="color:rgb(106,153,85)">#KSR::HDR.remove("Contact") if KSR::HDR.is_present('Contact') > 0</span></div><div>  <span style="color:rgb(106,153,85)">#KSR::HDR.append("Contact: #{uri}\r\n")  </span></div><div>  <span style="color:rgb(78,201,176)">KSR</span>::<span style="color:rgb(78,201,176)">HDR</span>.rmappend(<span style="color:rgb(206,145,120)">"Contact"</span>, <span style="color:rgb(206,145,120)">"Contact: </span><span style="color:rgb(86,156,214)">#{</span>uri<span style="color:rgb(86,156,214)">}</span><span style="color:rgb(215,186,125)">\r\n</span><span style="color:rgb(206,145,120)">"</span>)</div><div><span style="color:rgb(197,134,192)">end</span></div></div></div><div><br></div><div>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" target="_blank">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><br></div><div><div><font size="1" face="Courier New">Record-Route: <<a>sip:1.2.3.4;lr;ftag=e3p42efd3635HH;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVFHDQAAs83AEGwAAFgwCQA8QY3RlZC5jb20uYXU-;did=927.f0f2</a>></font></div><div><font size="1" face="Courier New">…</font></div><div><font size="1" face="Courier New">Call-ID: 3de29646-e423-1238-e712-023563fb337c</font></div><div><font size="1" face="Courier New">CSeq: 17736747 INVITE</font></div><div><font size="1" face="Courier New"><a>sip:4.5.6.7:5060;alias=10.100.1.1~5060~1Content-Type:</a> application/sdp</font></div><div><font size="1" face="Courier New">Content-Length: 483</font></div><div><font size="1" face="Courier New">Contact: <<a>sip:61400123123@kamailio.test.uconnected.com.au</a>></font></div><div><br></div></div><div>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" target="_blank">kamailio.test.uconnected.com.au</a> resolves to, and is this Kamailio instance.</div><div><br></div><div>Here’s a copy of the same thing when I don’t call my replace_contact_header function and t_relay:</div><div><br></div><div><div><font size="1" face="Courier New">Record-Route: <<a>sip:1.2.3.4;lr;ftag=j6jebCSa5Qap6c;vst=AAAAAAAAAAAAAAAAAAAAAAoUXVND38dTgwEGEAEGwAAFgwCQA8Fdn83lZC5jb20uYXU-;did=827.40b</a>></font></div><div><font size="1" face="Courier New">...</font></div><div><font size="1" face="Courier New">Call-ID: 249571c5-e91a-ae91-6d8e-023563fb337c</font></div><div><font size="1" face="Courier New">CSeq: 17735867 INVITE</font></div><div><font size="1" face="Courier New">Contact: <<a>sip:4.5.6.7:5060;alias=10.100.1.1~5060~1</a>></font></div><div><font size="1" face="Courier New">Content-Type: application/sdp</font></div><div><font size="1" face="Courier New">Content-Length: 483</font></div><div><br></div></div><div>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><br></div><div>I’m currently using commit <a href="https://github.com/kamailio/kamailio/commit/283e46" target="_blank">283e468401d809ca9b71368c32badf3a70d48b8b</a> on Amazon Linux 2, which is CentOS/RHEL based.</div><div><br></div><div>Thanks!</div><div><br></div><div>Andrew</div></div>_______________________________________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>
_______________________________________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div>