Hello,

that can happen when you do many operations over the contact header (e.g., functions like fix_natted_contact()), see more details for a similar case at:

  * https://www.kamailio.org/wiki/tutorials/faq/main#why_parts_of_fromto_header_app

If you need many operations, then you have to use msg_apply_changes() in between.

Cheers,
Daniel

On 06.01.21 17:05, Devang Dhandhalya wrote:
in my requirement call coming from sbc to kamailio proxy and we route to pbx server in that when 
kamailio proxy get the call at that time i am removing Contact header using remove_hf("Contact") and adding contact Header using append_hf("$uac_req(hdrs)") for route to PBX server . in that signaling i am getting modified Contact header but old contact header not removed properly some junks are remain in the signaling 

scenario : 

SBC ---------> Kamailio proxy ------> PBX

before using remove_hf("Contact") 

INVITE sip:user2@domain.org;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 10.212.xxx.xxx:port;branch=z9hG4bK-524287-1---8c5ac8642f321a9e
Max-Forwards: 70
Contact: <sip:user1@10.212.xxx.xxx:39931;transport=UDP>
To: <sip:user2@domain.org;transport=UDP>
From: <sip:user1@domain.org;transport=UDP>;tag=891fd646
Call-ID: t9Ff-fCrin_VN1IO9Xf1mA..
CSeq: 2 INVITE
Content-Type: application/sdp
Proxy-Authorization: Digest username="user1",realm="domain.org",nonce="5ff5a660afc72502212b4a611bb0d689efadafab",uri="sip:user2@domain.org;transport=UDP",response="f926e3742cbdcb8c68ea9b5
82ac2dc",cnonce="9b3276d6d37aaa6107a835df8e5b3a87",nc=00000001,qop=auth,algorithm=MD5
User-Agent: Z 3.15.40006 rv2.8.20
Allow-Events: presence, kpml, talk
Content-Length: 243

v=0
o=Z 0 0 IN IP4 10.212.xxx.xxx
s=Z
c=IN IP4 10.212.xxx.xxx
t=0 0
m=audio 8000 RTP/AVP 3 110 8 0 97 101
a=rtpmap:110 speex/8000
a=rtpmap:97 iLBC/8000
a=fmtp:97 mode=30
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=sendrecv


after using remove-hf("Contact") function removing contact header but some junks are left and that eats next To header line and breaks Invite packet 

INVITE sip:user2@domain.org:;transport=UDP SIP/2.0
Record-Route: <sip:172.xx.xx.xxx;lr=on;ftag=891fd646;vst=AAAAAFFTQVkuCENVXUEpHwNLAQEOSwdcDhwUcG9ydD1VRFA-;vsf=AAAAAFVCQ1U0ChwlAQMMHgBHHwFJVAYVYW5zcG9ydD1VRFA->
Via: SIP/2.0/UDP 172.xx.xx.xxx;branch=z9hG4bKbe4c.9743b885ad3452287530994a2cad6e50.0
Via: SIP/2.0/UDP 10.212.xxx.xxx:39931;rport=39931;received=172.xx.xx.x;branch=z9hG4bK-524287-1---8c5ac8642f321a9e
Max-Forwards: 69
sip:user1@172.xx.xx.x:39931;transport=UDPTo: <sip:user2@domain.org>
From: <sip:user1@domain.org>;tag=891fd646
Call-ID: t9Ff-fCrin_VN1IO9Xf1mA..
CSeq: 2 INVITE
Content-Type: application/sdp
User-Agent: Z 3.15.40006 rv2.8.20
Allow-Events: presence, kpml, talk
Content-Length: 534
Contact: <sip:user2@172.xx.xx.xxx:5060>

v=0
o=Z 0 0 IN IP4 10.212.xxx.xxx
s=Z
c=IN IP4 172.xx.xx.xxx
t=0 0
m=audio 11210 RTP/AVP 3 110 8 0 97 101
a=rtpmap:3 GSM/8000
a=rtpmap:110 speex/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:97 iLBC/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:97 mode=30
a=fmtp:101 0-16
a=sendrecv
a=rtcp:11211
a=ice-ufrag:lzjregPe
a=ice-pwd:RtA9x3jUWk4yNpJlzPL60nsRck
a=candidate:LhtmUSbPt9BJs4ZC 1 UDP 2130706431 172.16.16.163 11210 typ host
a=candidate:LhtmUSbPt9BJs4ZC 2 UDP 2130706430 172.16.16.163 11211 typ host


As you can see Contact header is gone but sip:1234@172.xx.xx.x:39931;transport=UDP part left before To header . and its breake invite packet .


Any suggestion will be highly appreciated.




Disclaimer
In addition to generic Disclaimer which you have agreed on our website, any views or opinions presented in this email are solely those of the originator and do not necessarily represent those of the Company or its sister concerns. Any liability (in negligence, contract or otherwise) arising from any third party taking any action, or refraining from taking any action on the basis of any of the information contained in this email is hereby excluded.

Confidentiality
This communication (including any attachment/s) is intended only for the use of the addressee(s) and contains information that is PRIVILEGED AND CONFIDENTIAL. Unauthorized reading, dissemination, distribution, or copying of this communication is prohibited. Please inform originator if you have received it in error.

Caution for viruses, malware etc.
This communication, including any attachments, may not be free of viruses, trojans, similar or new contaminants/malware, interceptions or interference, and may not be compatible with your systems. You shall carry out virus/malware scanning on your own before opening any attachment to this e-mail. The sender of this e-mail and Company including its sister concerns shall not be liable for any damage that may incur to you as a result of viruses, incompleteness of this message, a delay in receipt of this message or any other computer problems. 

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- 
Daniel-Constantin Mierla -- www.asipto.com
www.twitter.com/miconda -- www.linkedin.com/in/miconda
Funding: https://www.paypal.me/dcmierla