ARUNBALAN NV
ARUNBALAN NV

Reputation: 1662

How to change To header URI from Kamailio?

I am using Kamailio 4.4. I would like to forward the request to a different port number of my endpoint. I have changed the destination URI and the INVITE correctly reached the new port. But the To header in the INVITE request has the old port. so the endpoint is not responding to the request. Then I tried to remove and replace To header using remove_hf("To") and insert_hf("To: $var(modified_to_header) \r\n"); functions. But the to header not changed.

So, is there any way to change the To header URI?

Upvotes: 1

Views: 6285

Answers (1)

Daniel
Daniel

Reputation: 78

More info needed to give you a true answer but in general 'To' header not used in routing (replay). If the INVITE reached the new port you should get response anyway, even error.

So as I understand problem not in "To" header but in address to replay

Usually UAS sends replay to top 'Via' header or 'Contact' header when direct route used (you're not called record_route for example). This process described in rfc3261 Sections 4 and 18.2.2

So checking first this headers you can understand where replay sent. If you will see replay you will have more info to understand how to fix issue.

Anyway for forwarding packet to a different address/port better use internal core functions rewritehostport or similar https://www.kamailio.org/wiki/cookbooks/4.4.x/core#rewritehostport. Or modules like dispatcher,loadbalancer etc. It will do all duty work rewriting headers in a true manner for you automaticly

Here is quick examples

rewritehostport("1.2.3.4:5080");
rewriteport("5070");

To change 'To' header uac_replace_to from uac module should be used. But warn - in most cases it is no reason to do such rewrite and may have unpredictable effects because of tags stored in header. You should know exactly what you're doing.

uac_replace_to("sip:[email protected]:5090");

Hope this helps

Upvotes: 1

Related Questions