[Home]

Summary:ASTERISK-29208: res_pjsip: AMI Action PJSIPShowContacts returns No Contacts found
Reporter:Mikhail (j3st3r)Labels:patch
Date Opened:2020-12-10 08:19:29.000-0600Date Closed:
Priority:MinorRegression?
Status:Open/NewComponents:Core/ManagerInterface Resources/res_pjsip
Versions:16.9.0 16.11.1 16.15.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:ubuntu 18.04.4 debian 10Attachments:( 0) asterisk_pjsip_contacts_all_ami2.patch
( 1) t.18881-brief.txt
( 2) t.18881-full.txt
( 3) t.18881-info.txt
( 4) t.18881-locks.txt
( 5) t.18881-thread1.txt
Description:Hello. Faced a bug: sending PJSIPShowContacts action from ami libraries (panoramisk, ami-py) says "Message='No Contacts found' Response='Error' content=''>". while asterisk -rx 'pjsip show contacts' - shows contacts.


script example is here

from panoramisk import Manager
import asyncio

@asyncio.coroutine
def check_peers():
   manager = Manager(loop=loop,host='127.0.0.1', port=5038,username='123', secret='123')
   try:
       yield from manager.connect()
       peersobj = yield from manager.send_action({'Action': 'PJSIPShowContacts'})
       return peersobj
       manager.close()
   except:
       return 'oops...something is wrong'

loop = asyncio.get_event_loop()
peers = loop.run_until_complete(check_peers())
print(peers)


Other ami-commands (like PJSIPShowEndpoints, etc.) work fine.


here is nmap output


T 127.0.0.1:5038 -> 127.0.0.1:44054 [AP] #144
 Event: SuccessfulAuth..Privilege: security,all..EventTV: 2020-12-10T14:00:04.511+0000..Severity: Informational..Service: AMI..EventVersion: 1..AccountID: flask..SessionID: 0x7f06b806fd8
 0..LocalAddress: IPV4/TCP/127.0.0.1/5038..RemoteAddress: IPV4/TCP/127.0.0.1/44054..UsingPassword: 0..SessionTV: 2020-12-10T14:00:04.511+0000....
#
T 127.0.0.1:44054 -> 127.0.0.1:5038 [AP] #145
 Action: PJSIPShowContacts..ActionID: 1....
#
T 127.0.0.1:5038 -> 127.0.0.1:44054 [AP] #146
 Response: Error..ActionID: 1..Message: No Contacts found.....
Comments:By: Asterisk Team (asteriskteam) 2020-12-10 08:19:30.237-0600

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution. Please note that log messages and other files should not be sent to the Sangoma Asterisk Team unless explicitly asked for. All files should be placed on this issue in a sanitized fashion as needed.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

Please note that by submitting data, code, or documentation to Sangoma through JIRA, you accept the Terms of Use present at [https://www.asterisk.org/terms-of-use/|https://www.asterisk.org/terms-of-use/].

By: Joshua C. Colp (jcolp) 2020-12-10 08:34:27.757-0600

What is the actual output of "pjsip show contacts"?

By: Mikhail (j3st3r) 2020-12-10 08:43:29.552-0600

singapore*CLI> pjsip show contacts

 Contact:  <Aor/ContactUri..............................> <Hash....> <Status> <RTT(ms)..>
==========================================================================================

 Contact:  35060/sip:10.55.10.29:35060                    ea7d712854 Avail        79.149
 Contact:  35061/sip:10.55.10.29:35061                    009f24077c Avail        78.149
 Contact:  35062/sip:10.55.10.29:35062                    4847b46252 Avail        71.090
 Contact:  35063/sip:10.55.10.29:35063                    88d6e584f7 Avail        77.828
 Contact:  mm-sea-test/sip:south.lead b43a38ba48 Avail        12.116
 Contact:  prov-new-failover/sip:cc.virtuo.in         5fb53cac03 Avail         3.363
 Contact:  prov_virtuo/sip:cc.virtuo.in                   5fb53cac03 Avail         3.489
 Contact:  telecomsxchange/sip:sip01.telecomsxchange.com: 32fdb1328d Avail       203.024

By: Mikhail (j3st3r) 2020-12-10 09:53:19.238-0600

I found out the following: if peer was created in pjsip.conf - PJSIPShowContacts action - shows the peer. (example config -
[6001]
type=endpoint
context=internal
disallow=all
allow=ulaw
auth=auth6001
aors=6001
transport=udp-transport

[auth6001]
type=auth
auth_type=userpass
password=6001
username=6001

[6001]
type=aor
max_contacts=1
qualify_frequency = 60)


But if peer is pjsip_wizard -based - PJSIPShowContacts don't show it. Here is my wizard example -

[trunk_defaults](!)
type = wizard
transport = udp-transport
endpoint/allow_subscribe = no
endpoint/allow = !all,ulaw
aor/qualify_frequency = 30
registration/expiration = 1800
endpoint/inband_progress = yes

[telecomsxchange](trunk_defaults)
endpoint/context = from-trunk
remote_hosts = sip01.telecomsxchange.com:5060
sends_registrations = no
accepts_registrations = no
sends_auth = no
accepts_auth = no

By: Kevin Harwell (kharwell) 2020-12-10 09:55:48.646-0600

It appears you are using an older version of Asterisk. Does it still do this in the latest version?

--Also please attach your _pjsip.conf_ configuration.--
Edit: nvm I see you've done that now above

By: Mikhail (j3st3r) 2020-12-10 12:22:29.637-0600

I've updated Asterisk to current 16 version (16.15.0), the problem still exists.

By: Mikhail (j3st3r) 2020-12-10 12:43:51.530-0600

One more update: looks like it doesn't depend on pjsip or pjsip_wizard configuration. Looks like if peer has inbound registration (configured as internal extension) - PJSIPShowContacts shows it, but if peer has outbound registration or without registration - doesn't.

By: Mikhail (j3st3r) 2020-12-14 21:42:33.677-0600

Does anyone work with the issue?

By: Joshua C. Colp (jcolp) 2020-12-15 04:00:51.009-0600

There is noone working on this issue at this time. If that changes then it will be assigned and transition to "In Progress".

By: Diego Busacca (dbusacca) 2022-09-14 06:28:40.835-0500

This issue is still present in 16.28.0 and 18.14.0

The static contacts arent displayed by the AMI action {{PJSIPShowContacts}}

On my test server {{pjsip show contacts}} returns 44 contacs and {{PJSIPShowContacts}} only 9.

This issue prevents our software to monitor the qualify status of peers without registration.

{code}
tam*CLI> pjsip show contacts

 Contact:  <Aor/ContactUri..............................> <Hash....> <Status> <RTT(ms)..>
==========================================================================================
...
 Contact:  To_95.1/sip:172.16.95.1:5060                   2532df838c Avail         1.060
...
Objects found: 44
{code}


{{PJSIPShowContacts}}

{code}
<asterisk.ami.response.Response object at 0x7fa6e8732ba8>
Response: Success
ActionID: 1
EventList: start
Message: A listing of Contacts follows, presented as ContactList events
...
Event : ContactListComplete -> {'ActionID': '1', 'EventList': 'Complete', 'ListItems': '9'}

{code}

By: Filip Frank (frenk77) 2022-10-05 05:59:56.140-0500

I make a patch. Ut solve problem for us. But i dont know how to fill endpoint name so i use aor name instead. Its not problem for us because we always use same name for both. Maybe someone can make it better. Also im not experienced C programmer :(.  I just tried copy algorithm for cli pjsip show contacts command. At first i have no idea why there are separate places for static contacts and dynamic. Patch include some debug log messages, we testing it now, you can remove them for production usage. Works with 18.11.3.