PJSIP: Change the user part of the Contact Header


I try to change the user part of the contact header. I have configured a SIP trunk.
If I made an outbound call the INVITE message contains always the following contact header sip:asterisk@

I have trying some changes in the pjsip.conf but nothing works. I’ve got always the same contact header.

Can I change the user part in the contact header?

Thank a lot!

The only requirement on Contact headers is that they be recognizable by the entity that sets them and should route the response back to that entity. The user part does not have to represent anything meaningful in the real world.

What is the source of your requirement for semantics beyond those required by the RFCs?


Sorry, I have seen the first post missing the contact header example. Asterisk always includes the following contact header sip:asterisk@

I need the possibility to configure the value of the user port.
Especially I replace the value ‘asterisk’ with the user part of the from header.

For example, a SIP device with the phone number 12345 make an outgoing call to the SIP trunk.
The INVITE message of the SIP trunk should contains the following contact header sip:12345@ instead of sip:asterisk@

There is no valid reason why this should be necessary. As I already said, your device seems to be reading more into the Contact header than it is allowed to read into it.

As David mentions there should be no reason to do this, and as a result there is no ability to configure or change this without code modifcations.

Does that mean there is not a way to change the hardset ‘asterisk’ to some other value?

I don’t believe we’ve added a way to set such a thing, no. If we did it would be mentioned in the documentation for the pjsip.conf configuration.

Would you happen to know where this is set in source code?

It would start from ast_sip_create_dialog_uac in res_pjsip.c and trickle down from there. I don’t know precisely where.

ok, thanks! I will try and locate.

This seams like what I’m after, I may be mistaken though, I tried setting and doesn’t seam to change anything. Do you know what this does?

			<configOption name="contact_user" default="">
				<synopsis>Force the user on the outgoing Contact header to this value.</synopsis>
					On outbound requests, force the user portion of the Contact header to this value.

It appears to set the Contact user as documented, at least from looking at the code which is also in res_pjsip.c. I don’t know anything else about it.

Not sure what I miss-typed the first time, but this does work and changes the default ‘asterisk’ to the the value set.


Are you setting this in pjsip.conf or in the dialplan? We have a requirement from a carrier to dynamically set the contact for calls and I was looking for a way to do this.

I’d go with a supplier that implements SIP. The user part of the contact has no meaning to anything except the system that sent the Contact header. Often it doesn’t even have a meaning t that system.