PJSIP: Max callerID length?

Hi there,

I have a quick question, I am making a call between 2 asterisk, and I don’t know if there is a limit on the callerID length, I checked the docs and found nothing, any clues?

I’m on asterisk 18 with PJSIP

Thanks :slight_smile:

PJSIP has limits on total packet size and the size of a URI, although Asterisk might change them from the defaults:


There isn’t anything that I recognized as a limit on line length, or the name field.

I believe Asterisk still has limits on the expanded size of dialplan action lines, which could impact he ability to manipulate caller IDs. It could well have limits in the generic internal handling of caller IDs and might have limits in the interface between chan_pjsip and the PJSIP library code.

I’d suggest that the expectation of SIP is that they not be particularly long. I’d suggest that anything longer than would fit in a 72 character header is likely to be outside the spirit of SIP, although I suspect the first limit you would hit will be larger than that.

Hello @david551

Thanks for this explanation, I already found that there are a 80 characters limit on endpoints length, so I thought “Ok I will use the callerID to carry extra informations”

I understand that this seems not like a good idea, and I’m wondering how I can pass extra information when I’m making my call to my other asterisk ?

You can add arbitrary headers to the SIP INVITE[1] and access them on the other side.

[1] Asterisk 18 Function_PJSIP_HEADER - Asterisk Project - Asterisk Project Wiki

1 Like

Hi @jcolp ,

Thanks for your feedback, this is indeed the best way to do it, I haven’t thought of it ^^

I have two questions regarding the usage

If I set the header on my IPBX A, and send the call on IPBX B, and B is using realtime and stasis to process the calls, is the stasis application on B able to retrieve the X- header properly? when it should be done?

If I create a channel on my IPBX using stasis, then I set the X- header, can I get back it’s value later using the same channel object?


Dialplan functions can be called from ARI, for both setting and getting. You’re not able to set a header and then later retrieve it using PJSIP_HEADER though, you’d have to set it also as a normal dialplan variable.

I’m confused,

I thought based on your feedback that I can add my header using stasis with :

{'variables': {'PJSIP_HEADER(add,X-mycustomheader)': 'myvalue'}}

Then, my plan was to read it later when I want with GET /channels/{channelId}/PJSIP_HEADER

Also the documentation states that PJSIP_HEADER(action,name[,number]) have an action “read” but I’m not sure if it can be used with stasis to read the X- header value.

I don’t see why I have to deal with my dialplan, I am missing something I think.

Writing to PJSIP_HEADER adds a custom header to an outgoing SIP INVITE. Reading from PJSIP_HEADER reads a custom header from an incoming SIP INVITE. You can write or read from ARI.

If you add a custom header using PJSIP_HEADER you can not call PJSIP_HEADER on the same channel to get the value.

Asterisk ‘A’ calls Asterisk ‘B’.
PJSIP_HEADER is written on ‘A’ with ‘X-Test’ set to ‘Yes’.
PJSIP_HEADER is read on ‘B’. ‘X-Test’ will have a value of ‘Yes’.
PJSIP_HEADER is read on ‘A’. ‘X-Test’ will not have a value, because it’s not an incoming channel.

1 Like

Thanks for this really useful explanation!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.