PJSIP queue members showing as invalid

Does the queue application require state information on the devices in order to send calls with PJSIP?

We use realtime queues currently with chan_sip on Asterisk 13.18-cert2. We send our queue calls to a trunk in our environment. We do not have device registration information or state on our Asterisk. We simply run the Queue application and send the calls for the Queue members to a switch where device state is handled.

We are trying to upgrade to PJSIP, but we are running into a problem with our queue members showing up as invalid once we change our member interface from SIP/[member] to PJSIP/[member]. And so the result is that Asterisk does not send a call to the switch because Asterisk thinks there are no available queue members. I have outlined more details below:

In chan_sip, this is our asterisk_queue_member table that we use in extconfig.conf:

uniqueid   membername      queue_name      interface            penalty     paused
318550	   NULL	           22609	       SIP/sipdevice@trunk	1	        NULL

When we look at a queue, we see it is not in use:

sip09*CLI> queue show 22609
22609 has 0 calls (max unlimited) in 'rrmemory' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s
   Members:
      SIP/sipdevice@trunk with penalty 1 (ringinuse disabled) (realtime) (Not in use) has taken no calls yet
   No Callers

And when we call the Queue application from AGI:

EXEC Queue "22609,tr,,,300"

Asterisk sends the call for that device to the trunk (SIP/sipdevice@trunk) and everything works fine.

But, when we upgrade to PJSIP, we change the interface to be PJSIP:

uniqueid   membername      queue_name      interface            penalty     paused
318550	   NULL	           22609	       PJSIP/sipdevice@trunk	1	        NULL

And the member shows up as invalid.

sip07*CLI> queue show 22609
22609 has 0 calls (max unlimited) in 'rrmemory' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s
   Members:
      PJSIP/sipdevice@trunk with penalty 1 (ringinuse disabled) (realtime) (Invalid) has taken no calls yet
   No Callers

And so, when we execute the queue application on that queue (EXEC Queue "22609,tr,300”) we get “There are 0 available members”:

[2018-02-06 09:53:26] DEBUG[5461][C-00000000]: app_queue.c:5249 is_our_turn: There are 0 available members.
[2018-02-06 09:53:26] DEBUG[5461][C-00000000]: app_queue.c:5267 is_our_turn: It's not our turn (PJSIP/trunk-00000000).
[2018-02-06 09:53:26] DEBUG[5461][C-00000000]: res_config_mysql.c:1589 mysql_reconnect: MySQL RealTime: Connection okay.
[2018-02-06 09:53:26] DEBUG[5461][C-00000000]: res_config_mysql.c:495 realtime_multi_mysql: MySQL RealTime: Retrieve SQL: SELECT * FROM asterisk_queue_member WHERE interface LIKE '%' AND queue_name = '22609' ORDER BY interface

We are not seeing any errors on start up with the app_queue.so. Does PJSIP require us to have the device state information in order to send calls to queue members? Or is there a new setting we need to configure so that the queue application will see that we are trying to send the calls to a trunk, not a device directly?

PJSIP/sipdevice@trunk is not a valid name for an endpoint for device state in chan_pjsip. You would need to specify an alternative interface to monitor that is always available.

1 Like

what is a valid name for chan_pjsip? Or, is the problem that we do not have device state and so PJSIP won’t see the member as valid?

It expects PJSIP/, not a dial string.

What has to change from chan_sip to PJSIP for the queue interface setup? chan_sip seemed to not care that we defined the interface as a sip dial string (i.e. SIP/1234@trunk). But, what format does PJSIP need the interface to be so we can send a queue call to a trunk?

Gah, discourse ate the format.

PJSIP/<endpoint name>

Is the supported format.

ah, awesome! That fixed the Invalid error. But, how do I get the actual call to be sent to the member. In this example below 12345 should be the To user in the INVITE But, with this setup the call is going out back to the caller without a To user.

<PJSIP/edg-san-00000008>AGI Rx << EXEC Queue "22609,tr,,,300"
    -- AGI Script Executing Application: (Queue) Options: (22609,tr,,,300)
    -- Called PJSIP/edg-san
  == Using SIP RTP Audio TOS bits 184
  == Using SIP RTP Audio CoS mark 5
<--- Transmitting SIP request (1025 bytes) to UDP:XXXXXXX:5060 --->
INVITE sip:XXXXXXXX SIP/2.0
Via: SIP/2.0/UDP XXXXXXXXX:5060;rport;branch=z9hG4bKPjdac7726c-bb34-4818-b8c9-5c0bdefb8274
From: "John Doe" <sip:+15555555555@XXXXXXXXX>;tag=431f5e0c-3e25-4edc-b57e-6e7f7935591b
To: <sip:XXXXXXXXX>
Contact: <sip:asterisk@XXXXXXXXX:5060>
Call-ID: 4f020946-8ea5-4185-8a8b-68d5ee12fe0c
CSeq: 6559 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REGISTER, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX certified/13.8-cert1
Content-Type: application/sdp
Content-Length:   359

How do I define the To username to be the member?

sip07*CLI> queue show 22609
22609 has 0 calls (max unlimited) in 'rrmemory' strategy (0s holdtime, 0s talktime), W:0, C:0, A:0, SL:0.0% within 0s
   Members:
      12345 (PJSIP/trunk-endpoint from PJSIP/trunk-endpoint) with penalty 1 (ringinuse enabled) (realtime) (Not in use) has taken no calls yet
   No Callers

You would need to use a different interface and state interface. There are different fields when specifying the queue member. The interface is used for dialing them, the state interface is used for device state.

1 Like

Ok, I think I am understanding a little better. But, all the documentation I see only has one interface defined in the queue RealTime mysql table. I have the membername defined currently with the name that the To user should be.

Where do I define the state interface for dialing the actual member?

uniqueid   membername      queue_name      interface            penalty     paused
318550	   12345	       22609	       SIP/trunk	        1	        NULL

I am not familiar with how to do it in realtime.

Ah ok. Then we’ll have to stick with chan_sip for now on queues until we can figure out how to configure PJSIP with realtime queues.

Can you use a local channel?

Define something like

[localsets]
exten => _.,1,Dial(PJSIP/${EXTEN}@trunk,60)
 same => n,Hangup()

Then define the member as LOCAL/sipdevice@localsets in your queue.

To close the loop here. Using the local channel to dial out worked and sent the calls out as expected. So thank you. But, this route does not work if you need channel variables. I know there are ways to inherit them into the local channel, but it is not trivial. Thank you for your help!

Figured out that there is a state_interface column in the queue_members table for realtime on PJSIP. This is not documented anywhere, but I found it in ${asterisk_source_dir}/contrib/realtime/mysql/mysql_config.sql:

CREATE TABLE queue_members (
    queue_name VARCHAR(80) NOT NULL,
    interface VARCHAR(80) NOT NULL,
    uniqueid VARCHAR(80) NOT NULL,
    membername VARCHAR(80),
    state_interface VARCHAR(80),
    penalty INTEGER,
    paused INTEGER,
    PRIMARY KEY (queue_name, interface)
);

Then I used jcolp’s explanations over at this thread to figure out using PJSIP/trunk as the state_interface where trunk is a a defined endpoint and interface is PJSIP/device@trunk, which will cause Asterisk to send the INVITE with device as the To: user.