PJSIP, events and AORs

Hello,
I am looking for some ideas. I need to trace the status of phones using events. So I carefully listen to events and when a phone registers with a PJSIP credentials, I receive ContactStatus events with “Created” and “Reachable” status. So far so good. But what happens when the phone unregister itself? Nothing. No events are generated.

I think a ContactStatus event with a status of “Removed” (or something like that) should be generated. Am I wrong or is this already supported and I am not looking in the right place?

Leandro

If you are wanting to know the status of a device why don’t you use something like PeerStatus instead? That’s specifically for knowing if they are reachable or unreachable.

I really appreciate your help. PeerStatus “unreachable” event is generated only when the extension got unreachable, like when I register a phone and then pull the cord, but if I just unregister the extension, no event “unreachable” is generated, maybe because the extension is no more there.

When registering a PJSIP extension, all is good. I get:

Event ContactStatus with ContactStatus: Created
Event PeerStatus with PeerStatus: Reachable
Event ContactStatus with ContactStatus: Reachable

When I pull the plug from a PJSIP extension, all is good. I get:

Event ContactStatus with ContactStatus: Unreachable 
Event PeerStatus with PeerStatus: Unreachable

On Asterisk console I get the message

    -- Contact 108-DEVEL/sip:108-DEVEL@79.51.58.198:64393;ob is now Unreachable.  RTT: 0.000 msec
  == Endpoint 108-DEVEL is now Unreachable

The problem I noticed is when the extension unregisters from Asterisk

On Asterisk console I get the message

Removed contact 'sip:108-DEVEL@79.51.58.198:50247;ob' from AOR '108-DEVEL' due to request

But no event is generated on AMI.

The documentation states there can be a “Removed” ContactStatus, but I have never seen it being generated.

It is possible this problem is generated by a bad configuration on my database, here it is my data:

mysql> select * from ps_endpoints where id='108-DEVEL'\G;
*************************** 1. row ***************************
                           tech_id: 31
                                id: 108-DEVEL
                             te_id: 1
                         transport: transport-udp
                              aors: 108-DEVEL
                              auth: 108-DEVEL
                           context: authenticated
                          disallow: all
                             allow: alaw:20;ulaw:20;g729:20
                      direct_media: no
             connected_line_method: 
               direct_media_method: 
     direct_media_glare_mitigation: 
       disable_direct_media_on_nat: 
                         dtmf_mode: rfc4733
            external_media_address: 
                       force_rport: yes
                       ice_support: NULL
                       identify_by: NULL
                         mailboxes: 108@DEVEL
                       moh_suggest: NULL
                     outbound_auth: NULL
                    outbound_proxy: 
                   rewrite_contact: yes
                          rtp_ipv6: NULL
                     rtp_symmetric: yes
                    send_diversion: NULL
                          send_pai: NULL
                         send_rpid: NULL
                     timers_min_se: NULL
                            timers: NULL
               timers_sess_expires: NULL
                          callerid: PJSIP test <108>
                  callerid_privacy: NULL
                      callerid_tag: NULL
                            100rel: NULL
                     aggregate_mwi: NULL
                  trust_id_inbound: NULL
                 trust_id_outbound: NULL
                         use_ptime: NULL
                          use_avpf: NULL
                  media_encryption: NULL
                   inband_progress: yes
                        call_group: NULL
                      pickup_group: NULL
                  named_call_group: NULL
                named_pickup_group: NULL
              device_state_busy_at: NULL
                        fax_detect: NULL
                         t38_udptl: NULL
                      t38_udptl_ec: NULL
             t38_udptl_maxdatagram: NULL
                     t38_udptl_nat: NULL
                    t38_udptl_ipv6: NULL
                         tone_zone: NULL
                          language: 
               one_touch_recording: NULL
                 record_on_feature: NULL
                record_off_feature: NULL
                        rtp_engine: NULL
                    allow_transfer: NULL
                   allow_subscribe: no
                         sdp_owner: NULL
                       sdp_session: NULL
                         tos_audio: NULL
                         tos_video: NULL
                    sub_min_expiry: NULL
                       from_domain: NULL
                         from_user: NULL
                     mwi_from_user: NULL
                       dtls_verify: NULL
                        dtls_rekey: NULL
                    dtls_cert_file: NULL
                  dtls_private_key: NULL
                       dtls_cipher: NULL
                      dtls_ca_file: NULL
                      dtls_ca_path: NULL
                        dtls_setup: NULL
                       srtp_tag_32: NULL
                     media_address: NULL
                   redirect_method: NULL
                           set_var: NULL
                   message_context: astsms
                         force_avp: NULL
      media_use_received_transport: NULL
                       accountcode: DEVEL
       media_encryption_optimistic: NULL
                     user_eq_phone: NULL
                    rpid_immediate: NULL
                 g726_non_standard: NULL
                     rtp_keepalive: NULL
                       rtp_timeout: NULL
                  rtp_timeout_hold: NULL
         bind_rtp_to_media_address: NULL
                         cos_audio: NULL
                         cos_video: NULL
                              deny: NULL
                            permit: NULL
                               acl: NULL
                      contact_deny: NULL
                    contact_permit: NULL
                       contact_acl: NULL
               voicemail_extension: NULL
mwi_subscribe_replaces_unsolicited: NULL
                 subscribe_context: NULL
                fax_detect_timeout: NULL
                      contact_user: NULL
              asymmetric_rtp_codec: NULL
1 row in set (0.00 sec)
mysql> select * from ps_aors where id='108-DEVEL'\G;
*************************** 1. row ***************************
                  id: 108-DEVEL
             contact: NULL
  default_expiration: 60
           mailboxes: 108@DEVEL
        max_contacts: 3
  minimum_expiration: 10
     remove_existing: NULL
   qualify_frequency: 60
authenticate_qualify: NULL
  maximum_expiration: 60
      outbound_proxy: NULL
        support_path: NULL
     qualify_timeout: 60
 voicemail_extension: NULL
1 row in set (0.00 sec)
mysql> select * from ps_auths where id='108-DEVEL'\G;
*************************** 1. row ***************************
            id: 108-DEVEL
     auth_type: userpass
nonce_lifetime: NULL
      md5_cred: NULL
      password: ***********************
         realm: NULL
      username: 108-DEVEL
1 row in set (0.00 sec)

That should still cause the endpoint state to change. What version of Asterisk are you using?

I am using Asterisk 13.20.0

Do you think it is a bug or a wrong configuration on my side?

If we really aren’t raising an event for that, then it would be a bug.