Endpoint active channel count does not decrease after PickupChan

Hi,

I have a setting were i have 10 pjsip endpoints 100X. in the dialplan i have a section to pickup ringing channels.

exten = _900X,1,PickupChan(PJSIP/100${EXTEN:3:4},p)

Use case: 1002 calls 1004. while 1004 ringing, 1001 dials 9004 and picks up channel. here is the pjsip list endpoints before and after the call is hung up.

Endpoint: <Endpoint/CID…> <State…> <Channels.>
Endpoint: 1001/1001 Busy 1 of 1
Endpoint: 1002/1002 Busy 1 of 1
Endpoint: 1003/1003 Unavailable 0 of 1
Endpoint: 1004/1004 Not in use 0 of 1

-- Channel PJSIP/1001-0000001d left 'native_rtp' basic-bridge <ab754efe-413c-4a0e-98ab-2f4bfe4d73b4>
-- Channel PJSIP/1002-0000001b left 'native_rtp' basic-bridge <ab754efe-413c-4a0e-98ab-2f4bfe4d73b4>

== Spawn extension (internal-main, 1004, 4) exited non-zero on ‘PJSIP/1002-0000001b’
– Executing [h@internal-main:1] Hangup(“PJSIP/1002-0000001b”, “”) in new stack
== Spawn extension (internal-main, h, 1) exited non-zero on 'PJSIP/1002-0000001b’
asterisk15*CLI> pjsip list endpoints

Endpoint: <Endpoint/CID…> <State…> <Channels.>
Endpoint: 1001/1001 Not in use 1 of 1
Endpoint: 1002/1002 Not in use 0 of 1
Endpoint: 1003/1003 Unavailable 0 of 1
Endpoint: 1004/1004 Not in use 0 of 1

The call count of 1001 is not decreased. after a few repetition of the same use case here is the state –

Endpoint: <Endpoint/CID…> <State…> <Channels.>
Endpoint: 1001/1001 Not in use 5 of 1
Endpoint: 1002/1002 Not in use 0 of 1
Endpoint: 1003/1003 Unavailable 0 of 1
Endpoint: 1004/1004 Not in use 0 of 1

Although 1001 is configured to device_busy_at=1, i can still call it!

I have a application that decides endpoint is busy through ari call to get endpoint and find channel_ids.size

Is there a another way where i can decide if an endpoint is not in a call?

Is this a bug? it does not decrease unless asterisk is restarted.

Tested in asterisk 13.8-cert4 and 15.2.1. fails in both cases.

Please help.

That would be a bug, it should not have that channel associated with it any further. Please file an issue[1]. As for knowing if an endpoint is busy you should use the deviceState route[2] instead.

[1] https://issues.asterisk.org/jira
[2] https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Devicestates+REST+API#Asterisk13DevicestatesRESTAPI-get

1 Like

Thanks for the reply.

I have created an issue —
https://issues.asterisk.org/jira/browse/ASTERISK-27691

Can you check whether it was created properly?

1 Like

It was created. If you can view it, then it was created fine. It will be triaged later and if additional information is required then it will be asked for.

ok thanks.

apparently i cant just say ok thanks. :frowning:

can you tell me how to link a pjsip endpoint to a devicestate so that i can call the ari?

You pass in the endpoint, which would be “PJSIP/” for example “PJSIP/alice”. Request device state for that endpoint and you will receive it.

i tried the https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Devicestates+REST+API#Asterisk13DevicestatesRESTAPI-list
which replied blank.

That gives you ARI controlled device states in case you are doing custom device states controlled over ARI. That will not list PJSIP device states. You need to explicitly use the “GET /deviceStates/{deviceName}” get route with “PJSIP/” as the device name. ie: “GET /deviceStates/PJSIP/alice”

1 Like

So i tried a specific /deviceStates/PJSIP/1001 and it throws exception

“message”: “Resource not found”

ok my mistake it need PJSIP%2F1001 and it worked.

Thanks a lot jcolp. :slight_smile: