asterisk / asterisk

The official Asterisk Project repository.
https://www.asterisk.org
Other
2.19k stars 970 forks source link

[bug]: queue_log + virtual agent + bridge broke all #313

Open slavonnet opened 1 year ago

slavonnet commented 1 year ago

Severity

Trivial

Versions

20.4.0

Components/Modules

app_queue

Operating Environment

FreePBX last modules updated.

Custom virtual device map context

context agent-login {
/*
        _***8XXX =>  {
                Set(DB(DEVSAVE/${EXTEN:3:4}/exten2cid)=${REALCALLERIDNUM});
                Set(DB(DEVSAVE/${REALCALLERIDNUM}/cid2exten)=${EXTEN:3:4});

                Set(ee=${DB(DEVSAVE/${REALCALLERIDNUM}/cid2exten)});
                Set(cc=${DB(DEVSAVE/${ee}/exten2cid)});
                Set(DB(DEVICE/${ee}/dial)=PJSIP/${cc});

                Set(DB(AMPUSER/${cc}/hint)=PJSIP/${cc}&Custom:DND${cc},CustomPresence:${cc});
                Set(DB(AMPUSER/${ee}/hint)=PJSIP/${cc}&Custom:DND${ee},CustomPresence:${ee});

                QueueLog(1500,${UNIQUEID},"Local/${EXTEN:3:4}@from-queue/n","MAP",${REALCALLERIDNUM});

                AGI(agi://127.0.0.1/user_login_out.agi,login,${REALCALLERIDNUM},${EXTEN:3:4});

                Hangup();
        }
        _*** =>  {
                Set(ee=${DB(DEVSAVE/${REALCALLERIDNUM}/cid2exten)});
                Set(cc=${DB(DEVSAVE/${ee}/exten2cid)});

                Set(DB(DEVICE/${cc}/user)=${cc});
                Set(DB(AMPUSER/${cc}/user)=${cc});
                Set(DB(AMPUSER/${cc}/device)=${cc});
                Set(DB(AMPUSER/${cc}/concurrency_limit)=3);

                Set(DB(AMPUSER/${ee}/device)=${ee});
                Set(DB(DEVICE/${ee}/dial)=VIRTUAL/${ee});

                Set(DB(AMPUSER/${cc}/hint)=PJSIP/${cc}&Custom:DND${cc},CustomPresence:${cc});
                Set(DB(AMPUSER/${ee}/hint)=Custom:DND${ee},CustomPresence:${ee});

                QueueLog(1500,${UNIQUEID},"Local/${ee}@from-queue/n","UNMAP",${REALCALLERIDNUM});

                AGI(agi://127.0.0.1/user_login_out.agi,logout,${REALCALLERIDNUM},${ee});

                Hangup();

        }
  }

Frequency of Occurrence

None

Issue Description

Step for reproduce

  1. Add context to ast
  2. ad PJSIP extension 7000-7500 . This is physical place for agent
  3. add 800-8500 virtual extension number for Agent Firstname Lastname
  4. add agent to queue (DYNAMIC)
  5. AGENT must call on 7xxx phone

    • ***8XXX - Map 8xxx to 7xxx device
    • *45 - login to default queue

    For test 1 use Cisco 7940 phone. When call is coming FreePBX call to 2 lines together in one time. Then agent answer any call and record call was gone, but... If agent transfer call to another queue then new calls not coming, no records to queues log. When second gent answer snd end call then in queue log add two records with same call talk trime.

    My 2 days debugging show me : When cisco get 2 calls and answer on CEL log i see sometime answer to BOTH channels. And as i understand log used another bridge for 3+ channels. After agent endc call and transfer bridge dontr broke and simple added new agent to exists room.

    P.S. Tho calls because dial string result is PJSIP/7001&PJSIP/7001. P.P.S. Ш екн ещ рфсл end emulate User&Device mode because activation it broke Extension Manager and other used commercial modules.

IPPS understand that first its bad configuration, but its great point for fine fix races and monkey config. PPPS If you don't understand my english gramma simple translate to russian and to english. times and world order fill be fix ) If you l;language have free wold order rules, then you understand me i guess )

calllog.txt

Relevant log output

example log in file

Asterisk Issue Guidelines

jcolp commented 1 year ago

This is the Asterisk project, not the FreePBX project. Issues involving FreePBX should be filed with FreePBX first to ensure it is not as a result of FreePBX. If afterwards it is determined that there is an issue in Asterisk then it can be opened with Asterisk.

slavonnet commented 1 year ago

@jcolp a bug in the code of answering the call and dialing the device when duplicating the device . Secondly, if you remember me, I used to contribute patches and was even in the top of the comments. I know how the asterisk works inside. I have not looked at the code, but most likely the error is that because of two parallel responses, the bridge application is replaced by a 4+ part version, and this module is buggy with the work of queues and with the state system. FreePBX allowed you to create a configuration with such a case, but you have a bug in the modules, you do not need to translate the arrows.

jcolp commented 1 year ago

I still don't understand. I'll leave this open though.

jcolp commented 1 year ago

I can say, though, that if a Local channel is involved then the Queue application has no idea that transfers occur. Changing this is architecturally difficult.

slavonnet commented 1 year ago

@jcolp 1. Why, if 2 calls are answered at the same time, a conference is created,? Why is it that when one call is clearly drop off by the device, then it remains hanging in the system? Why doesn't the channel roll back to SIMPLE mode after all this? Why is a conf channel allowed to be added to the queue app if it puts queue metrics and is not workable? As a workaround, I would split the channels into simple ones and add PCs separate, or wrap them in another simple bridge so that there is always a point-to-point connection supported in app queue.

jcolp commented 1 year ago

There are no such things as conference channels, or simple mode or simple channels, in Asterisk. Channels are channels. Local channels behave differently and have two channels to work within threading requirements. One channel can be transferred elsewhere, while the other channel remains.

If you want to try to improve the specific scenario with them and app_queue feel free.

slavonnet commented 1 year ago

@jcolp Again. I see TWO answers in CAL. Cisco hone i have ONE active call (no holds and second line usages). Asterisk don't see second channel halt. Its race condition bug because 50/50 chance to this side effect. Some time astyerisk see first answered call and drip second. But some time its its bridge tru channels (and dead also) but from docs it must save only first answered c channel on multipole dial string./ / Ш I think somewhere deadlock or race becouse asterisk gett 2 events in ope time for one common call in separate threads. I believe this good oint for check race logic!

jcolp commented 1 year ago

Okay. As I said, this issue is now open.