Force pjsip unregister from AMI

Hi,
I’ve tried to use action PJSIPUnregister but it does not work.

Here some test:

Action: PJSIPUnregister
Registration: 91200

Action: PJSIPUnregister
Registration: pjsip:91200

Action: PJSIPUnregister
Registration: pjsip:91200@PBX_IP

no one work

Is this form correct ?

Thanks

First, try getting a list of your registrations. You can do that from the Asterisk CLI, a la

asterisk*CLI> pjsip show registrations

 <Registration/ServerURI..............................>  <Auth..........>  <Status.......>
==========================================================================================

 myregistration/sip:server.example.com                        myauth         Registered      

Objects found: 1

The Registration you’re going to need for the AMI action is the Registration as noted above; that’d be myregistration in my case.

Then, from AMI, it’d look like:

Action: PJSIPUnregister
Registration: myregistration

Response: Success
Message: Unregistration sent

Event: Registry
Privilege: system,all
ChannelType: PJSIP
Username: sip:myregistration@server.example.com
Domain: sip:server.example.com
Status: Unregistered

If I then go check it, using the CLI again as an example, I’d see:

asterisk*CLI> pjsip show registrations

 <Registration/ServerURI..............................>  <Auth..........>  <Status.......>
==========================================================================================

 myregistration/sip:server.example.com                        myauth         Unregistered    

Objects found: 1

Note the change in status from the former Registered to the latter Unregistered

asterisk*CLI> pjsip show registrations
No objects found.

Probably I’m using the wrong command…
I need to force the unregistration of an extension, but I start to think that it is not correct, because the extension could re-register itself few seconds later…

This AMI command is for unregistering outbound registrations. Extensions registered to Asterisk are inbound registrations.

The AMI Action PJSIPUnregister unregisters a registration sent from Asterisk to an external system, as the Synopsis references:

Unregister an outbound registration.

Outbound, in this case, is outbound from Asterisk to something else.

As you realized, there isn’t much of a point in un-registering something registering to Asterisk, as it will just send a REGISTER request again later. You have a few options if you want to keep something REGISTER-ing with you:

  1. Change the password on the endpoint’s auth object. That will prevent any further registrations to that endpoint.

  2. Delete any registered contacts using ARI push configuration mechanisms. (If you want to kill the contacts immediately, that is.)

Assuming you want something else to register to that endpoint, you can always change the password on the auth object to something that some other new device knows.

1 Like

Thanks for the explanation.
The client extension must to do the unregister action ! :+1: