[PJSIP]: Dynamic register from Kamailio to Asterisk

Hello,

I have Kamailio configured to send a REGISTER to Asterisk whenever someone registers in Kamailio. The REGISTER message has a “from” field with the IP from the Kamailio server and the “contact” field from the registered user.

In Asterisk I created an endpoint and an AOR for every user, but Asterisk rejects the register with saying:

It seems that PJSIP uses the “from” field to match the endpoint instead of the “contact” field as it should be for a REGISTER.

This worked correctly with chan_sip. Is there any way to configure this correctly?

Kind regards
Jan Gaida

I disagree that a Contact should be used to identify the source of a message. A Contact is how to reach something, it may or may not contain identifying information.

In this scenario how are you expecting it to behave? Should each device have an endpoint?

As Johua says, Asterisk is behaving correctly. However Contact represents the address to which you want incoming calls to be directed, which will normally be the address from which you are sending REGISTER, but need not be.

Contact

The Contact header field provides a SIP or SIPS URI that can be used
to contact that specific instance of the UA for subsequent requests.
The Contact header field MUST be present and contain exactly one SIP
or SIPS URI in any request that can result in the establishment of a
dialog. For the methods defined in this specification, that includes
only the INVITE request. For these requests, the scope of the
Contact is global. That is, the Contact header field value contains
the URI at which the UA would like to receive requests, and this URI
MUST be valid even if used in subsequent requests outside of any
dialogs.

ietf.org/rfc/rfc3261.txt

Thank you already for you answers!

This is referring to a REGISTER scenario, something like a “third-party registration”. That means that a third-party (here: Kamailio) wants to register another device. So I put the URI of Kamailio in the from field and the URI of the device in the contact.

I understand that I have to configure a special endpoint for Kamailio identified by IP so that Asterisk can accept registration coming from there. I already have Endpoints and AORs for all my devices.

Now, when the registration comes in I expect Asterisk/PJSIP to match that registration to the endpoint I have configured for the device in the “contact” field.

Otherwise I do not know how to implement the correct registration procedure using Kamailio Proxy.

Without writing a custom endpoint identifier the PJSIP stuff won’t do that out of the box.

Thank you, I will look into creating an endpoint identifier module.

For the moment, I have found that it works when I assign the AORs from all devices to the Kamailio endpoint.
The problem is that I have to edit a comma-separated list of AORs in MySQL every time I add or remove an endpoint. There should be a special table associating AORs and endpoints to simplify the process.

Your use case is different to most other people and the added complexity of having to manage another table (and another configuration section if using .conf) would impose more work for everyone else. Having it on the endpoint makes sense for the rest.