When max_contacts for a PJSIP endpoint is set greater than 1, and remove_existing is set to no, it will ensure that the first endpoints to register to a particular endpoint will not be overwritten by subsequent registrations that exceed max_contacts.
I have run into a problem several times now, especially when my endpoints are behind SonicWALL routers, that the external port for the device will change aggressively, the device will reregister on that new port, and therefore max_contacts will be hit. The funny thing is that all of the existing contacts preventing the registration will not QUALIFY and are UNAVAILABLE. This seems incorrect to me; if a device is attempting to register, and there are no available contact slots, we should remove an unavailable contact to make room for the registration. We know we have a good endpoint on the other line, and are holding a spot for an AWoL endpoint and no-one gets online.
I have submitted a patch to Asterisk to change this behavior, and the developers disagree that this patch is needed or correct.
I’m posting this here so if anyone is interested in seeing that this patch is either merged or discarded should comment on the JIRA issue here:
[ASTERISK-29525] PJSIP remove_existing unavailable contacts - Digium/Asterisk JIRA
Your feedback will be appreciated.