Asterisk: "in call" queue member status, while actually no calls

Roman asked:

My asterisk won’t direct inbound calls to certain queue members, because it thinks that they are busy receiving another call. But they are not. They are waiting for a call (register and waiting), or even unavailable at all (unregister).

This is ‘sip show peers‘, where you can see 101 and 104 peers offline:

101/101                 (Unspecified)                            D  Yes        Yes            0        Unmonitored                                  
104/104                 (Unspecified)                            D  Yes        Yes            0        Unmonitored                                  

This is ‘queue show‘, where these peers are still considered as ‘in call‘:

      SIP/101 (ringinuse disabled) (in call) (Unavailable) has taken 216 calls (last was 6522 secs ago)
      SIP/148 (ringinuse disabled) (Not in use) has taken 254 calls (last was 6 secs ago)
      SIP/181 (ringinuse disabled) (in call) (In use) has taken 251 calls (last was 379 secs ago)
      SIP/104 (ringinuse disabled) (in call) (Unavailable) has taken 219 calls (last was 6524 secs ago)

My first clue is this hapenned somehow after certain calls were not finished correctly (which described as (last was 6522 secs ago) and (last was 6524 secs ago)). But I saw UNREGISTER headers myself, and even asterisk admits peers are offline: (Unavailable).

So how can they be in call if they are offline?
What could be the reason asterisk thinks that peers are in call when they are not (this is a problem, because it won’t let them receive any calls).

How do I fix this? How to prevent this from happening in future?

My answer:

Most likely the devices unregistered while on calls.

Once the devices re-register, the queue should notice that they aren’t on a call and mark them Not in use again.

If you actually saw the devices unregister, then you’ll want to figure out why they did that, and fix the problem from that end.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.