Hi all,
Hope everyone is well, and looking forward to seeing you all whenever Kamailio World ends up being!
I’m currently dealing with an issue which I’m unsure if it’s due to my own implementation, or a bug.
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:
def replace_contact_header(uri)
#KSR::HDR.remove("Contact") if KSR::HDR.is_present('Contact') > 0
#KSR::HDR.append("Contact: #{uri}\r\n")
KSR::HDR.rmappend("Contact", "Contact: #{uri}\r\n")
end
Note that I have tried both rmappend and the commented out functions too. I call this with a custom built URI, such as <
61400123123@kamailio.test.uconnected.com.au>. 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):
…
Call-ID: 3de29646-e423-1238-e712-023563fb337c
CSeq: 17736747 INVITE
Content-Length: 483
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
kamailio.test.uconnected.com.au resolves to, and is this Kamailio instance.
Here’s a copy of the same thing when I don’t call my replace_contact_header function and t_relay:
...
Call-ID: 249571c5-e91a-ae91-6d8e-023563fb337c
CSeq: 17735867 INVITE
Content-Type: application/sdp
Content-Length: 483
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.
Thanks!
Andrew