Custom config files do not work properly because FreePBX reuses section names

custom config files do not work properly because FreePBX reuses section names

For example, if I create a trunk called MyTrunk, FreePBX creates this:

pjsip.endpoint.conf

[MyTrunk]
transport=0.0.0.0-udp

pjsip.registration.conf

[MyTrunk]
transport=0.0.0.0-udp

If I then use pjsip.registration_custom.conf (or _post.conf) and I do this:

[MyTrunk](+)
transport=MyTransport

That does not work because FreePBX has created 2 sections called [MyTrunk] so the custom rules doesn’t apply to the registration (or it applies to the wrong one).

If I create a new section called

[MyOtherTrunk]

and then do

[MyOtherTrunk](+)

it works as expected, but I can’t do that to modify the sections that FreePBX creates.

It DOES work to modify endpoint sections, because that is the first section that FreePBX puts into pjsip.conf, but no sections after that works if they were already used previously.

FreePBX should not be re-using section names, it should be using something like [endpoint-MyTrunk] and [aor-MyTrunk] and [registration-MyTrunk] etc to remove ambiguity so that asterisk can properly use the custom files.

Asterisk doesn’t ‘re-use’ any context, it applies the lastly requested dialplan that applies, know that any ‘includes’ are included sequentially inline and any includes in an included file also, so put your customizations in the last appropriate ‘include’ or you can pre-empt that effect by defining your own root context in ‘/etc/asterisk/extensions_override_freepbx.conf’

I’m not sure what you are trying to modify. I am guessing that you want to use MyTransport for registration but leave 0.0.0.0-udp for the endpoint. If so, I would put in pjsip_custom_post.conf (where I put all customizations):
[MyTrunk](+type=registration)
transport=MyTransport

If that isn’t working for you, post the output (from the Asterisk command prompt) of
pjsip show registration MyTrunk
pjsip show endpoint MyTrunk

1 Like

The key point here is that, when you are overriding chan_pjsip configuration you should include type=xxxx.

Ok, so here is an actual example:

#pjsip.transports_custom.conf
[transport-MyTransport]
type=transport
protocol=tls
bind=0.0.0.0:5062
external_media_address=x.x.x.x
external_signaling_address=x.x.x.x
...etc...

#pjsip.endpoint_custom_post.conf
[MyTrunk](+)
transport=transport-MyTransport

#pjsip.registration_custom_post.conf
[MyTrunk](+)
transport=transport-MyTransport

#pjsip show endpoint MyTrunk
transport : transport-MyTransport

#pjsip show registration MyTrunk
transport : 0.0.0.0-udp

Notice that in the endpoint, the transport has been successfully modified, but in the registration, the transport is still showing the original value from pjsip.registration.conf instead of the override value in pjsip.registration_custom_post.conf

@david55

I tried doing the following per your suggestion (or at least what I thought you meant) but the results were the same:

#pjsip.registration_custom_post.conf
[MyTrunk](+)
transport=transport-MyTransport
type=registration

#pjsip show endpoint MyTrunk
transport : transport-MyTransport

#pjsip show registration MyTrunk
transport : 0.0.0.0-udp

@Stewart1

Your suggestion of putting type after the + worked (although I still put it in pjsip.registration_custom_post.conf), but WHY does [MyTrunk](+) work for endpoints, but [MyTrunk](+) does NOT work for registration?

When I used [MyTrunk](+type=registration) for registration like you suggested, it worked.

Why the difference in which one works? My thought is because [MyTrunk] has already been used and modified as an endpoint name, and therefore it confuses the parser when it is now used and modified as a registration name, but dicko stated that shouldn’t be the case and that asterisk applies them in order.

Probably the order in which the original sections are read.

1 Like