Attended transfer don't release channel

Hi, I have 2 asterisk (from source 1.8.x) systems that works in a different way, but the configuration is almost the same. I can’t find the solution for attended transfers.

SYSTEM I:
A -> B
A -> B -> C (transfer)
After B hangs up, Asterisk executes block h@wew (from channel SIP) because B was disconnected and then executes h@macro-telwew (from channel Transfered/SIP) because transfer was completed.
We ave connection:
A -> C
and B becomes ready to use (i.e. in queue) even during A -> C conversation. This is good.

SYSTEM II:
A -> B
A -> B -> C (transfer)
After B hangs up, Asterisk executes only block h@wew for channel Transfered/SIP (not SIP like above). B is not released.
A -> C (conversation is blocking B)
After disconnection asterisk releases C and B one after another.

LOGs for transfer on both systems:

SYSTEM 1 (correct):

[quote]Connected to Asterisk 1.8.10.1~dfsg-1ubuntu1 currently running on ubuntu-VirtualBox (pid = 6791)
Verbosity is at least 3
– Registered SIP ‘90’ at 192.168.101.53:5060
– Registered SIP ‘91’ at 192.168.101.53:5060
== Using SIP RTP CoS mark 5
[Mar 12 23:07:56] NOTICE[6822]: chan_sip.c:22622 handle_request_invite: Call from ‘22’ (192.168.101.53:5060) to extension ‘901’ rejected because extension not found in context ‘wew’.
== Using SIP RTP CoS mark 5
– Executing [90@wew:1] Set(“SIP/22-0000003c”, “__TRANSFER_CONTEXT=tran”) in new stack
– Executing [90@wew:2] Set(“SIP/22-0000003c”, “__EXTERNAL_NUM=22”) in new stack
– Executing [90@wew:3] Macro(“SIP/22-0000003c”, “telwew,90”) in new stack
– Executing [s@macro-telwew:1] Set(“SIP/22-0000003c”, “__F=1426198081.72”) in new stack
– Executing [s@macro-telwew:2] Set(“SIP/22-0000003c”, “__BBPOLACZENIE_ID=”) in new stack
– Executing [s@macro-telwew:3] ChanIsAvail(“SIP/22-0000003c”, “SIP/90”) in new stack
== Using SIP RTP CoS mark 5
– Executing [s@macro-telwew:4] NoOp(“SIP/22-0000003c”, “Dostepny kanal: SIP/90-0000003d”) in new stack
– Executing [s@macro-telwew:5] ExecIf(“SIP/22-0000003c”, “0?Hangup()”) in new stack
– Executing [s@macro-telwew:6] Verbose(“SIP/22-0000003c”, "0,Uakt tel nr wew 90 polaczenie : ,1426198081.72 ") in new stack
Uakt tel nr wew 90 polaczenie : ,1426198081.72
– Executing [s@macro-telwew:7] Set(“SIP/22-0000003c”, “NUMER_ZEW=22”) in new stack
– Executing [s@macro-telwew:8] Set(“SIP/22-0000003c”, “CallTime=2015_03_12_23_08”) in new stack
– Executing [s@macro-telwew:9] Set(“SIP/22-0000003c”, “CALLFILENAME=90_2015_03_12_23_08_22_1426198081.72”) in new stack
– Executing [s@macro-telwew:10] Set(“SIP/22-0000003c”, “ODBC_REJ_FASTZILLA(22,90,1426198081.72)=0”) in new stack
– Executing [s@macro-telwew:11] Wait(“SIP/22-0000003c”, “0.”) in new stack
– Executing [s@macro-telwew:12] Set(“SIP/22-0000003c”, “CZAS=2015-03-12-23:08:01”) in new stack
– Executing [s@macro-telwew:13] NoOp(“SIP/22-0000003c”, “ODDZIAL: , CLID: , DST: “) in new stack
– Executing [s@macro-telwew:14] ExecIf(“SIP/22-0000003c”, “1=0?Set(NUMER_ZEW=22):Set(NUMER_ZEW=)”) in new stack
– Executing [s@macro-telwew:15] GotoIf(“SIP/22-0000003c”, “0?s-tak2:s-nie”) in new stack
– Goto (macro-telwew,s,16)
– Executing [s@macro-telwew:16] NoOp(“SIP/22-0000003c”, “NIE”) in new stack
– Executing [s@macro-telwew:17] Set(“SIP/22-0000003c”, “ODBC_REJ_BBPOLACZENIE(“1426198081.72”,””,“22”,“2015-03-12-23:08:01”,“1”)=0”) in new stack
– Executing [s@macro-telwew:18] Set(“SIP/22-0000003c”, “__BBPOLACZENIE_ID=31476”) in new stack
– Executing [s@macro-telwew:19] Goto(“SIP/22-0000003c”, “s-tak2”) in new stack
– Goto (macro-telwew,s,23)
– Executing [s@macro-telwew:23] Set(“SIP/22-0000003c”, “ODBC_REJ_BBROZMOWA(“31476”,“90”,“2015-03-12-23:08:01”)=0”) in new stack
– Executing [s@macro-telwew:24] Set(“SIP/22-0000003c”, “__BBROZMOWA_ID=53985”) in new stack
– Executing [s@macro-telwew:25] NoOp(“SIP/22-0000003c”, “31476, CHANNEL=SIP”) in new stack
– Executing [s@macro-telwew:26] GotoIf(“SIP/22-0000003c”, “1?s-zamknij_loc:s-dial”) in new stack
– Goto (macro-telwew,s,27)
– Executing [s@macro-telwew:27] GotoIf(“SIP/22-0000003c”, “0=0?s-zamknij_loc2:s-zamknij_loc1”) in new stack
– Goto (macro-telwew,s,28)
– Executing [s@macro-telwew:28] Set(“SIP/22-0000003c”, “ODBC_ROZ_BBROZMOWA(53985,2015-03-12-23:08:01,)=0”) in new stack
– Executing [s@macro-telwew:29] NoOp(“SIP/22-0000003c”, “1426198081.72,2015-03-12-23:08:01,53985”) in new stack
– Executing [s@macro-telwew:30] GotoIf(“SIP/22-0000003c”, “0?dial2:dial1”) in new stack
– Goto (macro-telwew,s,32)
– Executing [s@macro-telwew:32] Monitor(“SIP/22-0000003c”, “wav,53985,b”) in new stack
– Executing [s@macro-telwew:33] ChanIsAvail(“SIP/22-0000003c”, “SIP/90”) in new stack
== Using SIP RTP CoS mark 5
– Executing [s@macro-telwew:34] NoOp(“SIP/22-0000003c”, “Dostepny kanal: SIP/90-0000003e”) in new stack
– Executing [s@macro-telwew:35] Set(“SIP/22-0000003c”, “GROUP()=90-calls”) in new stack
– Executing [s@macro-telwew:36] GotoIf(“SIP/22-0000003c”, “0?busy”) in new stack
– Executing [s@macro-telwew:37] ExecIf(“SIP/22-0000003c”, “1?Dial(SIP/90,40,TtRr):Hangup()”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/90
– SIP/90-0000003f is ringing
– SIP/90-0000003f answered SIP/22-0000003c
[Mar 12 23:08:05] WARNING[7745]: res_rtp_asterisk.c:2135 ast_rtp_read: RTP Read too short
[Mar 12 23:08:05] WARNING[7745]: res_rtp_asterisk.c:2135 ast_rtp_read: RTP Read too short
– Started music on hold, class ‘default’, on SIP/22-0000003c
– <SIP/90-0000003f> Playing ‘pbx-transfer.ulaw’ (language ‘pl’)
– Executing [91@tran:1] Set(“Local/91@tran-dfb6;2”, “_TransToExt=91”) in new stack
– Executing [91@tran:2] NoOp(“Local/91@tran-dfb6;2”, “**************************IN TRANSFER 91”) in new stack
– Executing [91@tran:3] Set(“Local/91@tran-dfb6;2”, “CALLERID(num)=22”) in new stack
– Executing [91@tran:4] Macro(“Local/91@tran-dfb6;2”, “telwew,91”) in new stack
– Executing [s@macro-telwew:1] Set(“Local/91@tran-dfb6;2”, “__F=1426198081.72”) in new stack
– Executing [s@macro-telwew:2] Set(“Local/91@tran-dfb6;2”, “__BBPOLACZENIE_ID=31476”) in new stack
– Executing [s@macro-telwew:3] ChanIsAvail(“Local/91@tran-dfb6;2”, “SIP/91”) in new stack
== Using SIP RTP CoS mark 5
– Executing [s@macro-telwew:4] NoOp(“Local/91@tran-dfb6;2”, “Dostepny kanal: SIP/91-00000040”) in new stack
– Executing [s@macro-telwew:5] ExecIf(“Local/91@tran-dfb6;2”, “0?Hangup()”) in new stack
– Executing [s@macro-telwew:6] Verbose(“Local/91@tran-dfb6;2”, "0,Uakt tel nr wew 91 polaczenie : ,1426198094.77 ") in new stack
Uakt tel nr wew 91 polaczenie : ,1426198094.77
– Executing [s@macro-telwew:7] Set(“Local/91@tran-dfb6;2”, “NUMER_ZEW=22”) in new stack
– Executing [s@macro-telwew:8] Set(“Local/91@tran-dfb6;2”, “CallTime=2015_03_12_23_08”) in new stack
– Executing [s@macro-telwew:9] Set(“Local/91@tran-dfb6;2”, “CALLFILENAME=91_2015_03_12_23_08_22_1426198094.77”) in new stack
– Executing [s@macro-telwew:10] Set(“Local/91@tran-dfb6;2”, “ODBC_REJ_FASTZILLA(22,91,1426198094.77)=0”) in new stack
– Executing [s@macro-telwew:11] Wait(“Local/91@tran-dfb6;2”, “0.”) in new stack
– Executing [s@macro-telwew:12] Set(“Local/91@tran-dfb6;2”, “CZAS=2015-03-12-23:08:14”) in new stack
– Executing [s@macro-telwew:13] NoOp(“Local/91@tran-dfb6;2”, "ODDZIAL: , CLID: , DST: ") in new stack
– Executing [s@macro-telwew:14] ExecIf(“Local/91@tran-dfb6;2”, “1=0?Set(NUMER_ZEW=22):Set(NUMER_ZEW=)”) in new stack
– Executing [s@macro-telwew:15] GotoIf(“Local/91@tran-dfb6;2”, “1?s-tak2:s-nie”) in new stack
– Goto (macro-telwew,s,23)
– Executing [s@macro-telwew:23] Set(“Local/91@tran-dfb6;2”, “ODBC_REJ_BBROZMOWA(“31476”,“91”,“2015-03-12-23:08:14”)=0”) in new stack
– Executing [s@macro-telwew:24] Set(“Local/91@tran-dfb6;2”, “__BBROZMOWA_ID=53986”) in new stack
– Executing [s@macro-telwew:25] NoOp(“Local/91@tran-dfb6;2”, “31476, CHANNEL=Loc”) in new stack
– Executing [s@macro-telwew:26] GotoIf(“Local/91@tran-dfb6;2”, “0?s-zamknij_loc:s-dial”) in new stack
– Goto (macro-telwew,s,30)
– Executing [s@macro-telwew:30] GotoIf(“Local/91@tran-dfb6;2”, “0?dial2:dial1”) in new stack
– Goto (macro-telwew,s,32)
– Executing [s@macro-telwew:32] Monitor(“Local/91@tran-dfb6;2”, “wav,53986,b”) in new stack
– Executing [s@macro-telwew:33] ChanIsAvail(“Local/91@tran-dfb6;2”, “SIP/91”) in new stack
== Using SIP RTP CoS mark 5
– Executing [s@macro-telwew:34] NoOp(“Local/91@tran-dfb6;2”, “Dostepny kanal: SIP/91-00000041”) in new stack
– Executing [s@macro-telwew:35] Set(“Local/91@tran-dfb6;2”, “GROUP()=91-calls”) in new stack
– Executing [s@macro-telwew:36] GotoIf(“Local/91@tran-dfb6;2”, “0?busy”) in new stack
– Executing [s@macro-telwew:37] ExecIf(“Local/91@tran-dfb6;2”, “1?Dial(SIP/91,40,TtRr):Hangup()”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/91
– Local/91@tran-dfb6;1 is ringing
– SIP/91-00000042 is ringing
– Local/91@tran-dfb6;1 is ringing
– SIP/91-00000042 answered Local/91@tran-dfb6;2
[Mar 12 23:08:18] WARNING[7746]: res_rtp_asterisk.c:2135 ast_rtp_read: RTP Read too short
– Executing [h@wew:1] NoOp(“SIP/90-0000003f”, ", ID: 1426198081.72, 2015-03-12-23:08:27) ") in new stack
– Executing [h@wew:2] GotoIf(“SIP/90-0000003f”, “0?odebrana”) in new stack
– Executing [h@wew:3] GotoIf(“SIP/90-0000003f”, “0?zamknij”) in new stack
– Executing [h@wew:4] NoOp(“SIP/90-0000003f”, ““AA””) in new stack
– Executing [h@wew:5] GotoIf(“SIP/90-0000003f”, “0?odebrana:dalej”) in new stack
– Goto (wew,h,11)
– Executing [h@wew:11] GotoIf(“SIP/90-0000003f”, “1?cancel:czyzamknac”) in new stack
– Goto (wew,h,12)
– Executing [h@wew:12] GotoIf(“SIP/90-0000003f”, “0=0?zamknij2:cancel2”) in new stack
– Goto (wew,h,13)
– Executing [h@wew:13] Set(“SIP/90-0000003f”, “ODBC_UPD_BBPOLACZENIE_WYBOR(1426198081.72,)=0”) in new stack
– Executing [h@wew:14] Set(“SIP/90-0000003f”, “ODBC_ROZ_BBROZMOWA(53985,2015-03-12-23:08:27,)=0”) in new stack
– Executing [h@wew:15] Goto(“SIP/90-0000003f”, “czyzamknac”) in new stack
– Goto (wew,h,16)
– Executing [h@wew:16] Set(“SIP/90-0000003f”, “ZAMKNAC=T”) in new stack
– Executing [h@wew:17] NoOp(“SIP/90-0000003f”, “SIP”) in new stack
– Executing [h@wew:18] GotoIf(“SIP/90-0000003f”, “1?zamknij:koniec”) in new stack
– Goto (wew,h,7)
– Executing [h@wew:7] GotoIf(“SIP/90-0000003f”, “0=0?zamknij2:zamknij1”) in new stack
– Goto (wew,h,8)
– Executing [h@wew:8] Set(“SIP/90-0000003f”, “ODBC_UPD_BBPOLACZENIE_WYBOR(1426198081.72,)=0”) in new stack
– Executing [h@wew:9] Set(“SIP/90-0000003f”, “ODBC_ROZ_BBROZMOWA(53985,2015-03-12-23:08:28,)=0”) in new stack
– Executing [h@wew:10] Goto(“SIP/90-0000003f”, “koniec”) in new stack
– Goto (wew,h,23)
– Executing [h@wew:23] StopMonitor(“SIP/90-0000003f”, “”) in new stack
– Executing [h@wew:24] System(“SIP/90-0000003f”, "/fastdata/konwertuj.sh 53985 ") in new stack
– Executing [h@wew:25] Hangup(“SIP/90-0000003f”, “”) in new stack
== Spawn extension (wew, h, 25) exited non-zero on ‘SIP/90-0000003f’
– Stopped music on hold on SIP/22-0000003c
– <Local/91@tran-dfb6;1> Playing ‘beep.ulaw’ (language ‘pl’)
– Executing [h@macro-telwew:1] NoOp(“Transfered/SIP/22-0000003c”, "ANSWER, ID: 1426198081.72, 2015-03-12-23:08:28) ") in new stack
– Executing [h@macro-telwew:2] GotoIf(“Transfered/SIP/22-0000003c”, “0?odebrana”) in new stack
– Executing [h@macro-telwew:3] GotoIf(“Transfered/SIP/22-0000003c”, “0?zamknij”) in new stack
– Executing [h@macro-telwew:4] NoOp(“Transfered/SIP/22-0000003c”, ““AA””) in new stack
– Executing [h@macro-telwew:5] GotoIf(“Transfered/SIP/22-0000003c”, “0?odebrana:dalej”) in new stack
– Goto (macro-telwew,h,11)
– Executing [h@macro-telwew:11] GotoIf(“Transfered/SIP/22-0000003c”, “0?cancel:czyzamknac”) in new stack
– Goto (macro-telwew,h,16)
– Executing [h@macro-telwew:16] Set(“Transfered/SIP/22-0000003c”, “ZAMKNAC=N”) in new stack
– Executing [h@macro-telwew:17] NoOp(“Transfered/SIP/22-0000003c”, “Tra”) in new stack
– Executing [h@macro-telwew:18] GotoIf(“Transfered/SIP/22-0000003c”, “0?zamknij:koniec”) in new stack
– Goto (macro-telwew,h,23)
– Executing [h@macro-telwew:23] StopMonitor(“Transfered/SIP/22-0000003c”, “”) in new stack
– Executing [h@macro-telwew:24] System(“Transfered/SIP/22-0000003c”, "/fastdata/konwertuj.sh 53985 ") in new stack
– Executing [h@macro-telwew:25] Hangup(“Transfered/SIP/22-0000003c”, “”) in new stack
== Spawn extension (macro-telwew, h, 25) exited non-zero on ‘Transfered/SIP/22-0000003c’
== Spawn extension (macro-telwew, s, 37) exited non-zero on ‘Transfered/SIP/22-0000003c’ in macro ‘telwew’
== Spawn extension (wew, 90, 3) exited non-zero on ‘Transfered/SIP/22-0000003c’
– Executing [h@macro-telwew:1] NoOp(“Local/91@tran-dfb6;2”, "ANSWER, ID: 1426198081.72, 2015-03-12-23:08:34) ") in new stack
– Executing [h@macro-telwew:2] GotoIf(“Local/91@tran-dfb6;2”, “0?odebrana”) in new stack
– Executing [h@macro-telwew:3] GotoIf(“Local/91@tran-dfb6;2”, “0?zamknij”) in new stack
– Executing [h@macro-telwew:4] NoOp(“Local/91@tran-dfb6;2”, ““AA””) in new stack
– Executing [h@macro-telwew:5] GotoIf(“Local/91@tran-dfb6;2”, “1?odebrana:dalej”) in new stack
– Goto (macro-telwew,h,6)
– Executing [h@macro-telwew:6] Set(“Local/91@tran-dfb6;2”, “ODBC_ODB_BBPOLACZENIE(1426198081.72,)=0”) in new stack
– Executing [h@macro-telwew:7] GotoIf(“Local/91@tran-dfb6;2”, “0=0?zamknij2:zamknij1”) in new stack
– Goto (macro-telwew,h,8)
– Executing [h@macro-telwew:8] Set(“Local/91@tran-dfb6;2”, “ODBC_UPD_BBPOLACZENIE_WYBOR(1426198081.72,)=0”) in new stack
– Executing [h@macro-telwew:9] Set(“Local/91@tran-dfb6;2”, “ODBC_ROZ_BBROZMOWA(53986,2015-03-12-23:08:34,ANSWER)=0”) in new stack
– Executing [h@macro-telwew:10] Goto(“Local/91@tran-dfb6;2”, “koniec”) in new stack
– Goto (macro-telwew,h,23)
– Executing [h@macro-telwew:23] StopMonitor(“Local/91@tran-dfb6;2”, “”) in new stack
– Executing [h@macro-telwew:24] System(“Local/91@tran-dfb6;2”, "/fastdata/konwertuj.sh 53986 ") in new stack
– Executing [h@macro-telwew:25] Hangup(“Local/91@tran-dfb6;2”, “”) in new stack
== Spawn extension (macro-telwew, h, 25) exited non-zero on ‘Local/91@tran-dfb6;2’
== Spawn extension (macro-telwew, s, 37) exited non-zero on ‘Local/91@tran-dfb6;2’ in macro ‘telwew’
== Spawn extension (tran, 91, 4) exited non-zero on ‘Local/91@tran-dfb6;2’
– Executing [h@macro-telwew:1] NoOp(“SIP/22-0000003c”, "ANSWER, ID: 1426198081.72, 2015-03-12-23:08:34) ") in new stack
– Executing [h@macro-telwew:2] GotoIf(“SIP/22-0000003c”, “1?odebrana”) in new stack
– Goto (macro-telwew,h,6)
– Executing [h@macro-telwew:6] Set(“SIP/22-0000003c”, “ODBC_ODB_BBPOLACZENIE(1426198081.72,)=0”) in new stack
– Executing [h@macro-telwew:7] GotoIf(“SIP/22-0000003c”, “0=0?zamknij2:zamknij1”) in new stack
– Goto (macro-telwew,h,8)
– Executing [h@macro-telwew:8] Set(“SIP/22-0000003c”, “ODBC_UPD_BBPOLACZENIE_WYBOR(1426198081.72,)=0”) in new stack
– Executing [h@macro-telwew:9] Set(“SIP/22-0000003c”, “ODBC_ROZ_BBROZMOWA(53985,2015-03-12-23:08:35,ANSWER)=0”) in new stack
– Executing [h@macro-telwew:10] Goto(“SIP/22-0000003c”, “koniec”) in new stack
– Goto (macro-telwew,h,23)
– Executing [h@macro-telwew:23] StopMonitor(“SIP/22-0000003c”, “”) in new stack
– Executing [h@macro-telwew:24] System(“SIP/22-0000003c”, "/fastdata/konwertuj.sh 53985 ") in new stack
– Executing [h@macro-telwew:25] Hangup(“SIP/22-0000003c”, “”) in new stack
== Spawn extension (macro-telwew, h, 25) exited non-zero on ‘SIP/22-0000003c’
[/quote]

SYSTEM II:

[quote]Connected to Asterisk 1.8.32.0 currently running on steel (pid = 12851)
Verbosity is at least 3
== Using SIP RTP CoS mark 5
– Executing [901@wew:1] Set(“SIP/107-0000003b”, “__F=1426197355.92”) in new stack
– Executing [901@wew:2] Set(“SIP/107-0000003b”, “__CLID=”) in new stack
– Executing [901@wew:3] Set(“SIP/107-0000003b”, “__ZEW_NUM=107”) in new stack
– Executing [901@wew:4] Set(“SIP/107-0000003b”, “__TRANSFER_CONTEXT=tran”) in new stack
– Executing [901@wew:5] Macro(“SIP/107-0000003b”, “zadzwon,901”) in new stack
– Executing [s@macro-zadzwon:1] Set(“SIP/107-0000003b”, “__F=1426197355.92”) in new stack
– Executing [s@macro-zadzwon:2] Set(“SIP/107-0000003b”, “__TRANSFER_CONTEXT=tran”) in new stack
– Executing [s@macro-zadzwon:3] Set(“SIP/107-0000003b”, “__BBPOLACZENIE_ID=”) in new stack
– Executing [s@macro-zadzwon:4] ChanIsAvail(“SIP/107-0000003b”, “SIP/901”) in new stack
== Using SIP RTP CoS mark 5
– Executing [s@macro-zadzwon:5] NoOp(“SIP/107-0000003b”, “Dostepny kanal: SIP/901-0000003c”) in new stack
– Executing [s@macro-zadzwon:6] ExecIf(“SIP/107-0000003b”, “0?Hangup()”) in new stack
– Executing [s@macro-zadzwon:7] Wait(“SIP/107-0000003b”, “0.1”) in new stack
– Executing [s@macro-zadzwon:8] Set(“SIP/107-0000003b”, “CZAS=2015-03-12-22:55:55”) in new stack
– Executing [s@macro-zadzwon:9] NoOp(“SIP/107-0000003b”, “ODDZIAL: , CLID: , DST: “) in new stack
– Executing [s@macro-zadzwon:10] ExecIf(“SIP/107-0000003b”, “1=0?Set(NUMER_ZEW=107):Set(NUMER_ZEW=)”) in new stack
– Executing [s@macro-zadzwon:11] GotoIf(“SIP/107-0000003b”, “0?s-tak2:s-nie”) in new stack
– Goto (macro-zadzwon,s,12)
– Executing [s@macro-zadzwon:12] NoOp(“SIP/107-0000003b”, “NIE”) in new stack
– Executing [s@macro-zadzwon:13] Set(“SIP/107-0000003b”, “ODBC_REJ_BBPOLACZENIE(“1426197355.92”,””,“107”,“2015-03-12-22:55:55”,“1”)=0”) in new stack
– Executing [s@macro-zadzwon:14] Set(“SIP/107-0000003b”, “__BBPOLACZENIE_ID=13619”) in new stack
– Executing [s@macro-zadzwon:15] Goto(“SIP/107-0000003b”, “s-tak2”) in new stack
– Goto (macro-zadzwon,s,19)
– Executing [s@macro-zadzwon:19] Set(“SIP/107-0000003b”, “ODBC_REJ_BBROZMOWA(“13619”,“901”,“2015-03-12-22:55:55”)=0”) in new stack
– Executing [s@macro-zadzwon:20] Set(“SIP/107-0000003b”, “__BBROZMOWA_ID=19006”) in new stack
– Executing [s@macro-zadzwon:21] NoOp(“SIP/107-0000003b”, “13619, CHANNEL=SIP”) in new stack
– Executing [s@macro-zadzwon:22] GotoIf(“SIP/107-0000003b”, “1?s-zamknij_loc:s-dial”) in new stack
– Goto (macro-zadzwon,s,23)
– Executing [s@macro-zadzwon:23] GotoIf(“SIP/107-0000003b”, “0=0?s-zamknij_loc2:s-zamknij_loc1”) in new stack
– Goto (macro-zadzwon,s,24)
– Executing [s@macro-zadzwon:24] Set(“SIP/107-0000003b”, “ODBC_ROZ_BBROZMOWA(19006,2015-03-12-22:55:55,)=0”) in new stack
– Executing [s@macro-zadzwon:25] NoOp(“SIP/107-0000003b”, “1426197355.92,2015-03-12-22:55:55,19006”) in new stack
– Executing [s@macro-zadzwon:26] GotoIf(“SIP/107-0000003b”, “0?dial2:dial1”) in new stack
– Goto (macro-zadzwon,s,28)
– Executing [s@macro-zadzwon:28] Monitor(“SIP/107-0000003b”, “wav,19006,b”) in new stack
– Executing [s@macro-zadzwon:29] ChanIsAvail(“SIP/107-0000003b”, “SIP/901/n”) in new stack
== Using SIP RTP CoS mark 5
– Executing [s@macro-zadzwon:30] NoOp(“SIP/107-0000003b”, “Dostepny kanal: SIP/901-0000003d”) in new stack
– Executing [s@macro-zadzwon:31] Set(“SIP/107-0000003b”, “GROUP()=901-calls”) in new stack
– Executing [s@macro-zadzwon:32] GotoIf(“SIP/107-0000003b”, “0?busy”) in new stack
– Executing [s@macro-zadzwon:33] ExecIf(“SIP/107-0000003b”, “1?Dial(SIP/901,40,TtRr):Hangup()”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/901
– SIP/901-0000003e is ringing
– SIP/901-0000003e answered SIP/107-0000003b
[Mar 12 22:55:58] WARNING[14663]: res_rtp_asterisk.c:2172 ast_rtp_read: RTP Read too short
[Mar 12 22:55:58] WARNING[14663]: res_rtp_asterisk.c:2172 ast_rtp_read: RTP Read too short
– Started music on hold, class ‘default’, on SIP/107-0000003b
– <SIP/901-0000003e> Playing ‘pbx-transfer.ulaw’ (language ‘pl’)
– Executing [902@tran:1] Set(“Local/902@tran-00000008;2”, “_TransToExt=902”) in new stack
– Executing [902@tran:2] Set(“Local/902@tran-00000008;2”, “__F=1426197355.92”) in new stack
– Executing [902@tran:3] NoOp(“Local/902@tran-00000008;2”, “**************************IN TRANSFER 902”) in new stack
– Executing [902@tran:4] Set(“Local/902@tran-00000008;2”, “CALLERID(num)=107”) in new stack
– Executing [902@tran:5] Macro(“Local/902@tran-00000008;2”, “zadzwon,902”) in new stack
– Executing [s@macro-zadzwon:1] Set(“Local/902@tran-00000008;2”, “__F=1426197355.92”) in new stack
– Executing [s@macro-zadzwon:2] Set(“Local/902@tran-00000008;2”, “__TRANSFER_CONTEXT=tran”) in new stack
– Executing [s@macro-zadzwon:3] Set(“Local/902@tran-00000008;2”, “__BBPOLACZENIE_ID=13619”) in new stack
– Executing [s@macro-zadzwon:4] ChanIsAvail(“Local/902@tran-00000008;2”, “SIP/902”) in new stack
== Using SIP RTP CoS mark 5
– Executing [s@macro-zadzwon:5] NoOp(“Local/902@tran-00000008;2”, “Dostepny kanal: SIP/902-0000003f”) in new stack
– Executing [s@macro-zadzwon:6] ExecIf(“Local/902@tran-00000008;2”, “0?Hangup()”) in new stack
– Executing [s@macro-zadzwon:7] Wait(“Local/902@tran-00000008;2”, “0.2”) in new stack
– Executing [s@macro-zadzwon:8] Set(“Local/902@tran-00000008;2”, “CZAS=2015-03-12-22:56:03”) in new stack
– Executing [s@macro-zadzwon:9] NoOp(“Local/902@tran-00000008;2”, "ODDZIAL: , CLID: , DST: ") in new stack
– Executing [s@macro-zadzwon:10] ExecIf(“Local/902@tran-00000008;2”, “1=0?Set(NUMER_ZEW=107):Set(NUMER_ZEW=)”) in new stack
– Executing [s@macro-zadzwon:11] GotoIf(“Local/902@tran-00000008;2”, “1?s-tak2:s-nie”) in new stack
– Goto (macro-zadzwon,s,19)
– Executing [s@macro-zadzwon:19] Set(“Local/902@tran-00000008;2”, “ODBC_REJ_BBROZMOWA(“13619”,“902”,“2015-03-12-22:56:03”)=0”) in new stack
– Executing [s@macro-zadzwon:20] Set(“Local/902@tran-00000008;2”, “__BBROZMOWA_ID=19007”) in new stack
– Executing [s@macro-zadzwon:21] NoOp(“Local/902@tran-00000008;2”, “13619, CHANNEL=Loc”) in new stack
– Executing [s@macro-zadzwon:22] GotoIf(“Local/902@tran-00000008;2”, “0?s-zamknij_loc:s-dial”) in new stack
– Goto (macro-zadzwon,s,26)
– Executing [s@macro-zadzwon:26] GotoIf(“Local/902@tran-00000008;2”, “0?dial2:dial1”) in new stack
– Goto (macro-zadzwon,s,28)
– Executing [s@macro-zadzwon:28] Monitor(“Local/902@tran-00000008;2”, “wav,19007,b”) in new stack
– Executing [s@macro-zadzwon:29] ChanIsAvail(“Local/902@tran-00000008;2”, “SIP/902/n”) in new stack
== Using SIP RTP CoS mark 5
– Executing [s@macro-zadzwon:30] NoOp(“Local/902@tran-00000008;2”, “Dostepny kanal: SIP/902-00000040”) in new stack
– Executing [s@macro-zadzwon:31] Set(“Local/902@tran-00000008;2”, “GROUP()=902-calls”) in new stack
– Executing [s@macro-zadzwon:32] GotoIf(“Local/902@tran-00000008;2”, “0?busy”) in new stack
– Executing [s@macro-zadzwon:33] ExecIf(“Local/902@tran-00000008;2”, “1?Dial(SIP/902,40,TtRr):Hangup()”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/902
– Local/902@tran-00000008;1 is ringing
– SIP/902-00000041 is ringing
– Local/902@tran-00000008;1 is ringing
– SIP/902-00000041 answered Local/902@tran-00000008;2
[Mar 12 22:56:05] WARNING[14672]: res_rtp_asterisk.c:2172 ast_rtp_read: RTP Read too short
– Stopped music on hold on SIP/107-0000003b
– <Local/902@tran-00000008;1> Playing ‘beep.ulaw’ (language ‘pl’)
– Executing [h@wew:1] NoOp(“Transfered/SIP/107-0000003b”, "ANSWER, ID: 1426197355.92, 2015-03-12-22:56:08) ") in new stack
– Executing [h@wew:2] GotoIf(“Transfered/SIP/107-0000003b”, “0?odebrana”) in new stack
– Executing [h@wew:3] GotoIf(“Transfered/SIP/107-0000003b”, “0?zamknij”) in new stack
– Executing [h@wew:4] NoOp(“Transfered/SIP/107-0000003b”, ““AA””) in new stack
– Executing [h@wew:5] GotoIf(“Transfered/SIP/107-0000003b”, “0?odebrana:dalej”) in new stack
– Goto (wew,h,11)
– Executing [h@wew:11] GotoIf(“Transfered/SIP/107-0000003b”, “0?cancel:czyzamknac”) in new stack
– Goto (wew,h,16)
– Executing [h@wew:16] Set(“Transfered/SIP/107-0000003b”, “ZAMKNAC=N”) in new stack
– Executing [h@wew:17] NoOp(“Transfered/SIP/107-0000003b”, “Tra”) in new stack
– Executing [h@wew:18] GotoIf(“Transfered/SIP/107-0000003b”, “0?zamknij:koniec”) in new stack
– Goto (wew,h,23)
– Executing [h@wew:23] StopMonitor(“Transfered/SIP/107-0000003b”, “”) in new stack
– Executing [h@wew:24] System(“Transfered/SIP/107-0000003b”, "/fastdata/konwertuj.sh 19006 ") in new stack
– Executing [h@wew:25] Hangup(“Transfered/SIP/107-0000003b”, “”) in new stack
== Spawn extension (wew, h, 25) exited non-zero on ‘Transfered/SIP/107-0000003b’
== Spawn extension (macro-zadzwon, s, 33) exited non-zero on ‘Transfered/SIP/107-0000003b’ in macro ‘zadzwon’
== Spawn extension (wew, 901, 5) exited non-zero on ‘Transfered/SIP/107-0000003b’
– Executing [h@tran:1] NoOp(“Local/902@tran-00000008;2”, “___END TRANSFER”) in new stack
– Executing [h@tran:2] GotoIf(“Local/902@tran-00000008;2”, “0?odebrana”) in new stack
– Executing [h@tran:3] GotoIf(“Local/902@tran-00000008;2”, “0?zamknij”) in new stack
– Executing [h@tran:4] NoOp(“Local/902@tran-00000008;2”, ““AA””) in new stack
– Executing [h@tran:5] GotoIf(“Local/902@tran-00000008;2”, “1?odebrana:dalej”) in new stack
– Goto (tran,h,6)
– Executing [h@tran:6] Set(“Local/902@tran-00000008;2”, “ODBC_ODB_BBPOLACZENIE(1426197355.92,)=0”) in new stack
– Executing [h@tran:7] GotoIf(“Local/902@tran-00000008;2”, “0=0?zamknij2:zamknij1”) in new stack
– Goto (tran,h,8)
– Executing [h@tran:8] Set(“Local/902@tran-00000008;2”, “ODBC_UPD_BBPOLACZENIE_WYBOR(1426197355.92,)=0”) in new stack
– Executing [h@tran:9] Set(“Local/902@tran-00000008;2”, “ODBC_ROZ_BBROZMOWA(19007,2015-03-12-22:56:13,ANSWER)=0”) in new stack
– Executing [h@tran:10] Goto(“Local/902@tran-00000008;2”, “koniec”) in new stack
– Goto (tran,h,23)
– Executing [h@tran:23] StopMonitor(“Local/902@tran-00000008;2”, “”) in new stack
– Executing [h@tran:24] System(“Local/902@tran-00000008;2”, "/fastdata/konwertuj.sh 19007 ") in new stack
– Executing [h@tran:25] Hangup(“Local/902@tran-00000008;2”, “”) in new stack
== Spawn extension (tran, h, 25) exited non-zero on ‘Local/902@tran-00000008;2’
== Spawn extension (macro-zadzwon, s, 33) exited non-zero on ‘Local/902@tran-00000008;2’ in macro ‘zadzwon’
== Spawn extension (tran, 902, 5) exited non-zero on ‘Local/902@tran-00000008;2’
– Executing [h@tran:1] NoOp(“SIP/107-0000003b”, “___END TRANSFER”) in new stack
– Executing [h@tran:2] GotoIf(“SIP/107-0000003b”, “1?odebrana”) in new stack
– Goto (tran,h,6)
– Executing [h@tran:6] Set(“SIP/107-0000003b”, “ODBC_ODB_BBPOLACZENIE(1426197355.92,)=0”) in new stack
– Executing [h@tran:7] GotoIf(“SIP/107-0000003b”, “0=0?zamknij2:zamknij1”) in new stack
– Goto (tran,h,8)
– Executing [h@tran:8] Set(“SIP/107-0000003b”, “ODBC_UPD_BBPOLACZENIE_WYBOR(1426197355.92,)=0”) in new stack
– Executing [h@tran:9] Set(“SIP/107-0000003b”, “ODBC_ROZ_BBROZMOWA(19006,2015-03-12-22:56:13,ANSWER)=0”) in new stack
– Executing [h@tran:10] Goto(“SIP/107-0000003b”, “koniec”) in new stack
– Goto (tran,h,23)
– Executing [h@tran:23] StopMonitor(“SIP/107-0000003b”, “”) in new stack
– Executing [h@tran:24] System(“SIP/107-0000003b”, "/fastdata/konwertuj.sh 19006 ") in new stack
– Executing [h@tran:25] Hangup(“SIP/107-0000003b”, “”) in new stack
== Spawn extension (tran, h, 25) exited non-zero on ‘SIP/107-0000003b’[/quote]

Could you please provide the actual dialplan as it is too complex to take in just from the trace.

In the meantime, note that a channel with a name like Transferred/xxxx is the original channel.

Hi, here is dialplan.

[general]

static=yes
writeprotect=no;
;autofallthrough=no
;extenpatternmatchnew=no
clearglobalvars=no

[globals]
CONSOLE=Console/dsp				; Console interface for demo
IAXINFO=guest					; IAXtel username/password
TRUNK=DAHDI/G0					; Trunk interface
TRYB=a
SERWIS_RUDA=bdc
SERWIS_DEP2=bdc
SALON_DEP1=bdc
SALON_DEP2=bdc
FLOTA=bdc
KOMIS=bdc
SKLEP_DEP1=sklep_DEP1
SKLEP_DEP2=sklep_DEP2
BLACHARNIA=bdc
UBEZP_DEP1=bdc
UBEZP_DEP2=bdc
KSIEGOWOSC=ksiegowosc
SKP=bdc
TRUNKMSD=1					; MSD digits to strip (usually 1 or 0)


[tran]
;transfer context
exten => _XXX,1,Set(_TransToExt=${EXTEN})
exten => _XXX,n,Set(__F=${IF(${ISNULL(${F})}=0?${UNIQUEID}:${F})})
exten => _XXX,n,NoOp(**************************IN TRANSFER ${TransToExt})
exten => _XXX,n,Set(CALLERID(num)=${ZEW_NUM})
exten => _XXX,n,Macro(zadzwon,${EXTEN})

exten => h,1,NoOp(___________________END TRANSFER________________)
exten => h,n,NoOp(${DIALSTATUS}, ID: ${F}, ${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)}) )
exten => h,n,GotoIf($["${CHANNEL:0:3}"="SIP"&["${DIALSTATUS}"="ANSWER"]]?odebrana)
exten => h,n,GotoIf($["${CHANNEL:0:3}"="SIP"&${ISNULL(${DIALSTATUS})}=0]?zamknij)
exten => h,n,NoOp("AA")
exten => h,n,GotoIf($["${DIALSTATUS}"="ANSWER"&"${CHANNEL:0:3}"="Loc"]?odebrana:dalej)
exten => h,n(odebrana),Set(ODBC_ODB_BBPOLACZENIE(${F},${kolejka})=0)
exten => h,n(zamknij),GotoIf(${ISNULL(${BBROZMOWA_ID})}=0?zamknij2:zamknij1)
exten => h,n(zamknij1),Set(ODBC_UPD_BBPOLACZENIE_WYBOR(${F},${kolejka})=0)
exten => h,n,Set(ODBC_ROZ_BBROZMOWA(${BBROZMOWA_ID},${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)},${DIALSTATUS})=0)
exten => h,n(odebrana),Goto(koniec)
exten => h,n(dalej),GotoIf($["${DIALSTATUS}"!="ANSWER"]?cancel:czyzamknac)
exten => h,n(cancel),GotoIf(${ISNULL(${BBROZMOWA_ID})}=0?zamknij2:cancel2)
exten => h,n(cancel2),Set(ODBC_UPD_BBPOLACZENIE_WYBOR(${F},${kolejka})=0)
exten => h,n,Set(ODBC_ROZ_BBROZMOWA(${BBROZMOWA_ID},${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)},${DIALSTATUS})=0)
exten => h,n,Goto(czyzamknac)
exten => h,n(czyzamknac),Set(ZAMKNAC=${IF(${ISNULL(${DIALSTATUS})}=0|"${CHANNEL:0:3}"="SIP"?T:N)})
exten => h,n,NoOp(${CHANNEL:0:3})
exten => h,n,GotoIf($["${ZAMKNAC}"="T"]?zamknij:koniec)
exten => h,n(zamknij),GotoIf(${ISNULL(${BBROZMOWA_ID})}=0?zamknij2:zamknij1)
exten => h,n(zamknij1),Set(ODBC_UPD_BBPOLACZENIE_WYBOR(${F},${kolejka})=0)
exten => h,n,Set(ODBC_ROZ_BBROZMOWA(${BBROZMOWA_ID},${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)},${DIALSTATUS})=0)
exten => h,n(zamknij2),Set(ODBC_ROZ_BBROZMOWA_DLA_ASTERIX_ID(${F},${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)})=0)
exten => h,n(koniec),StopMonitor()
exten => h,n,System(/fastdata/konwertuj.sh ${BBROZMOWA_ID} )
exten => h,n,Hangup()


[wew]

exten => s,1,Answer()
exten => 1,1,Background(zap_glowna2)
exten => 2,1,Playback(Kanclerz_1_8kh)

exten => 5001,1,Macro(tryb_a)
exten => 5002,1,Macro(tryb_b)
exten => 5003,1,SayAlpha(${TRYB})
exten => 5003,n,Hangup()
exten => 5005,1,Macro(dodaj,${CALLERID(number)})
exten => 5006,1,Macro(usun,${CALLERID(number)})

exten => _XXX,1,Set(__F=${IF(${ISNULL(${F})}=0?${UNIQUEID}:${F})})
exten => _XXX,n,Set(__CLID=${CLID})
exten => _XXX,n,Set(__ZEW_NUM=${CALLERID(number)})
exten => _XXX,n,Set(__TRANSFER_CONTEXT=tran)
exten => _XXX,n,Macro(zadzwon,${EXTEN})


exten => _NXXXXXXXX,1,ChanIsAvail(sip/dwg/${EXTEN})
exten => _NXXXXXXXX,n,NoOp(Dostepny kanal DWG: ${AVAILCHAN})
exten => _NXXXXXXXX,n,ExecIf($["${AVAILCHAN:0:3}"="SIP"]?Macro(zadzwon-zew-dwg,${EXTEN},${CALLERID(number)}):Macro(zadzwon-zew,${EXTEN}))
exten => _NXXXXXXXX,n,Macro(zadzwon-zew-dwg,${EXTEN},${CALLERID(number)})

exten => _XXXXXXXXXXXXX,s,Macro(zadzwon-zew,${EXTEN})
exten => _XXXXXXXXXXXXXX,s,Macro(zadzwon-zew,${EXTEN})

exten => 99,1,Answer
exten => 99,n,Set(__F=${UNIQUEID})
exten => 99,n,NoOp(Rozpoczynam wywolanie : ${F})
exten => 99,n,Queue(kan_test,t)
exten => h,1,NoOp(${DIALSTATUS}, ID: ${F}, ${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)}) )
exten => h,n,GotoIf($["${CHANNEL:0:3}"="SIP"&["${DIALSTATUS}"="ANSWER"]]?odebrana)
exten => h,n,GotoIf($["${CHANNEL:0:3}"="SIP"&${ISNULL(${DIALSTATUS})}=0]?zamknij)
exten => h,n,NoOp("AA")
exten => h,n,GotoIf($["${DIALSTATUS}"="ANSWER"&"${CHANNEL:0:3}"="Loc"]?odebrana:dalej)
exten => h,n(odebrana),Set(ODBC_ODB_BBPOLACZENIE(${F},${kolejka})=0)
exten => h,n(zamknij),GotoIf(${ISNULL(${BBROZMOWA_ID})}=0?zamknij2:zamknij1)
exten => h,n(zamknij1),Set(ODBC_UPD_BBPOLACZENIE_WYBOR(${F},${kolejka})=0)
exten => h,n,Set(ODBC_ROZ_BBROZMOWA(${BBROZMOWA_ID},${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)},${DIALSTATUS})=0)
exten => h,n(odebrana),Goto(koniec)
exten => h,n(dalej),GotoIf($["${DIALSTATUS}"!="ANSWER"]?cancel:czyzamknac)
exten => h,n(cancel),GotoIf(${ISNULL(${BBROZMOWA_ID})}=0?zamknij2:cancel2)
exten => h,n(cancel2),Set(ODBC_UPD_BBPOLACZENIE_WYBOR(${F},${kolejka})=0)
exten => h,n,Set(ODBC_ROZ_BBROZMOWA(${BBROZMOWA_ID},${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)},${DIALSTATUS})=0)
exten => h,n,Goto(czyzamknac)
exten => h,n(czyzamknac),Set(ZAMKNAC=${IF(${ISNULL(${DIALSTATUS})}=0|"${CHANNEL:0:3}"="SIP"?T:N)})
exten => h,n,NoOp(${CHANNEL:0:3})
exten => h,n,GotoIf($["${ZAMKNAC}"="T"]?zamknij:koniec)
exten => h,n(zamknij),GotoIf(${ISNULL(${BBROZMOWA_ID})}=0?zamknij2:zamknij1)
exten => h,n(zamknij1),Set(ODBC_UPD_BBPOLACZENIE_WYBOR(${F},${kolejka})=0)
exten => h,n(,Set(ODBC_ROZ_BBROZMOWA(${BBROZMOWA_ID},${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)},${DIALSTATUS})=0)
exten => h,n(zamknij2),Set(ODBC_ROZ_BBROZMOWA_DLA_ASTERIX_ID(${F},${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)})=0)
exten => h,n(koniec),StopMonitor()
exten => h,n,System(/fastdata/konwertuj.sh ${BBROZMOWA_ID} )
exten => h,n,Hangup()



[macro-zadzwon]
exten => s,1,Set(__F=${IF(${ISNULL(${F})}=0?${UNIQUEID}:${F})})
exten => s,n,Set(__TRANSFER_CONTEXT=tran)
exten => s,n,Set(__BBPOLACZENIE_ID=${BBPOLACZENIE_ID})
exten => s,n,ChanIsAvail(SIP/${ARG1})
exten => s,n,NoOp(Dostepny kanal: ${AVAILCHAN})
exten => s,n,ExecIf($["${AVAILCHAN:0:3}"!="SIP"]?Hangup())
exten => s,n,Wait(0.${ARG1:2:3})
exten => s,n,Set(CZAS=${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)})
exten => s,n,NoOp(ODDZIAL: ${ODDZIAL}, CLID: ${CLID}, DST: ${DST})
exten => s,n,ExecIf(${ISNULL(${CLID})}=0?Set(NUMER_ZEW=${CALLERID(number)}):Set(NUMER_ZEW=${CLID}))
exten => s,n,GotoIf($[${ISNULL(${BBPOLACZENIE_ID})}=0]?s-tak2:s-nie)
exten => s,n(s-nie),NoOp(NIE)
exten => s,n,Set(ODBC_REJ_BBPOLACZENIE("${F}","${DST}","${NUMER_ZEW}","${CZAS}","1")=0)
exten => s,n,Set(__BBPOLACZENIE_ID=${ODBC_REJ_BBPOLACZENIE_NEW("${F}")})
exten => s,n,Goto(s-tak2)
exten => s,n(s-tak),NoOp(TAK)
exten => s,n,Set(__BBPOLACZENIE_ID=${ODBC_REJ_BBPOLACZENIE_NEW("${F}")})
exten => s,n,Goto(s-tak2)
exten => s,n(s-tak2),Set(ODBC_REJ_BBROZMOWA("${BBPOLACZENIE_ID}","${ARG1}","${CZAS}")=0)
exten => s,n,Set(__BBROZMOWA_ID=${ODBC_REJ_BBROZMOWA("${BBPOLACZENIE_ID}","${ARG1}","${CZAS}")})
exten => s,n,NoOp(${BBPOLACZENIE_ID}, CHANNEL=${CHANNEL:0:3})
exten => s,n,GotoIf($["${CHANNEL:0:3}"="SIP"]?s-zamknij_loc:s-dial)
exten => s,n(s-zamknij_loc),GotoIf(${ISNULL(${BBROZMOWA_ID})}=0?s-zamknij_loc2:s-zamknij_loc1)
exten => s,n(s-zamknij_loc1),Set(ODBC_ROZ_BBROZMOWA(${BBROZMOWA_ID},${CZAS},${DIALSTATUS})=0)
exten => s,n(s-zamknij_loc2),NoOp(${F},${CZAS},${BBROZMOWA_ID})
exten => s,n(s-dial)(dial),GotoIf($["${DST}" = "109"]?dial2:dial1)
exten => s,n(s-dial)(dial),GotoIf($["${CALLERID(number)}" = "109"]?dial2:dial1)
exten => s,n(dial1),Monitor(wav,${BBROZMOWA_ID},b)
exten => s,n(dial2),ChanIsAvail(SIP/${ARG1}/n)
exten => s,n,NoOp(Dostepny kanal: ${AVAILCHAN})
exten => s,n,Set(GROUP()=${ARG1}-calls)
exten => s,n,GotoIf($[${GROUP_COUNT(${ARG1}-calls)} > 1]?busy)
exten => s,n,ExecIf($["${AVAILCHAN:0:3}"="SIP"]?Dial(SIP/${ARG1},40,TtRr):Hangup())
exten => s,n(busy),Busy(10)
exten => s,n,Hangup

[macro-zadzwon-zew]
exten => s,1,Set(__F=${IF(${ISNULL(${F})}=0?${UNIQUEID}:${F})})
exten => s,n,Set(CID=${IF($["${ARG2:0:1}"= "1"]?327XXXXXX:323019999)})
exten => s,n,Set(CALLERID(all)="Kanclerz" <${CID}>)
exten => s,n,NoOp(ODDZIAL: ${ODDZIAL}, EXT: ${ARG2})
exten => s,n,Set(__BBPOLACZENIE_ID=${ODBC_REJ_BBPOLACZENIE_NEW("${F}")})
exten => s,n,Set(__CZYMAMYBBPOL=${IF(${ISNULL(${BBPOLACZENIE_ID})}=0?T:N)})
exten => s,n,GotoIf($[${CZYMAMYBBPOL}=T]?:t,n)
exten => s,n,Set(CZAS=${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)})
exten => s,n(n),Set(ODBC_REJ_BBPOLACZENIE_NEW("${F}","${ARG1}","${CALLERID(number)}","${CZAS}","2")=0)
exten => s,n,Set(__BBPOLACZENIE_ID=${ODBC_REJ_BBPOLACZENIE_NEW("${F}")})
exten => s,n(t),Set(ODBC_REJ_BBROZMOWA("${BBPOLACZENIE_ID}","${CALLERID(number)}","${CZAS")=0)
exten => s,n,Set(__BBROZMOWA_ID=${ODBC_REJ_BBROZMOWA("${BBPOLACZENIE_ID}","${CALLERID(number)}","${CZAS}")})
exten => s,n(dial),GotoIf($["${DST}" = "109"]?dial2:dial1) ;don't record 109
exten => s,n,GotoIf($["${CALLERID(number)}" = "109"]?dial2:dial1)
exten => s,n(dial1),Monitor(wav,${BBROZMOWA_ID},b)
exten => s,n,Set(GROUP()=${CALLERID(number)}-calls)
exten => s,n(dial2),Dial(dahdi/g0/${ARG1})

[macro-zadzwon-zew-dwg]
exten => s,1,Set(__F=${IF(${ISNULL(${F})}=0?${UNIQUEID}:${F})})
exten => s,n,Set(CID=${IF($["${ARG2:0:1}"= "1"]?327XXXXXX:323019999)})
exten => s,n,NoOp(ODDZIAL: ${ODDZIAL}, EXT: ${ARG2})
exten => s,n,Set(__BBPOLACZENIE_ID=${ODBC_REJ_BBPOLACZENIE_NEW("${F}")})
exten => s,n,Set(__CZYMAMYBBPOL=${IF(${ISNULL(${BBPOLACZENIE_ID})}=0?T:N)})
exten => s,n,GotoIf($[${CZYMAMYBBPOL}=T]?:t,n)
exten => s,n(n),Set(ODBC_REJ_BBPOLACZENIE_NEW("${F}","${ARG1}","${CALLERID(number)}","${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)}","2")=0)
exten => s,n,Set(__BBPOLACZENIE_ID=${ODBC_REJ_BBPOLACZENIE_NEW("${F}")})
exten => s,n(t),Set(ODBC_REJ_BBROZMOWA("${BBPOLACZENIE_ID}","${CALLERID(number)}","${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)}")=0)
exten => s,n,Set(__BBROZMOWA_ID=${ODBC_REJ_BBROZMOWA("${BBPOLACZENIE_ID}","${CALLERID(number)}","${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)}")})
exten => s,n(dial),GotoIf($["${DST}" = "109"]?dial2:dial1) ;don't record 109
exten => s,n,GotoIf($["${CALLERID(number)}" = "109"]?dial2:dial1)
exten => s,n(dial1),Monitor(wav,${BBROZMOWA_ID},b)
exten => s,n,Set(GROUP()=${CALLERID(number)}-calls)
exten => s,n(dial2),Dial(sip/dwg/${ARG1},60)



[ipfon]
exten => s,1,Answer()
exten => s,n,Set(__F=${UNIQUEID})
exten => s,n,Set(__ODDZIAL=dep1)
exten => s,n,Set(__DST=717156291)
exten => s,n,NoOp(${CHANNEL})
exten => s,n,Set(CZAS=${STRFTIME(${EPOCH},,%Y-%m-%d-%H:%M:%S)})
exten => s,n,Set(ODBC_REJ_BBPOLACZENIE("${F}","717156291","${CALLERID(number)}","${CZAS}","1")=0)
exten => s,n,Set(__BBPOLACZENIE_ID=${ODBC_REJ_BBPOLACZENIE_NEW("${F}")})
exten => s,n,Background(zap_glowna2)
exten => s,n,WaitExten(5)

exten => 5001,1,Macro(tryb_a)
exten => 5002,1,Macro(tryb_b)
exten => 5003,1,SayPhonetic(${TRYB})
exten => 5003,n,Hangup()

exten => 1,1,GotoIf($[{ODDZIAL}="dep2"]?dep21:dep11)
exten => 1,n(dep21),Queue(bdc,t)
exten => 1,n(dep11),Queue(bdc,t)

;exten => s,n,Queue(kan_test,t)

[zamkniete]
exten => _XXXXXXXXX,1,Answer() // answer the inbound call
exten => _XXXXXXXXX,n,Set(__kolejka="Zapowiedz po godzinach")
exten => _XXXXXXXXX,n,Set(__F=${UNIQUEID})
exten => _XXXXXXXXX,n,Set(__ODDZIAL="dep1")
exten => _XXXXXXXXX,n,Set(__DST=${EXTEN})
exten => _XXXXXXXXX,n,Background(zap_pogodzinach)
exten => _XXXXXXXXX,n,WaitExten(5)
exten => 1,1,VoiceMail(1000@default)
exten => _XXXXXXXXX,n,Hangup()
exten => _XXX,1,Set(__kolejka="Wybor wewn. po godz.: ${EXTEN}")
exten => _XXX,n,Set(__TRANSFER_CONTEXT=tran)
exten => _XXX,n,Dial(Local/${EXTEN}@wew/n)

[from-pstn]

exten => 3224208XX,1,Answer() // answer the inbound call
exten => 3224208XX,n,GotoIfTime(19:00-7:00,mon-fri,*,*?zamkniete)
exten => 3224208XX,n,GotoIfTime(15:00-23:59,sat,*,*?zamkniete)
exten => 3224208XX,n,GotoIfTime(*,sun,*,*?zamkniete)
exten => 3224208XX,n,Set(__kolejka="Zapowiedz glowna")
exten => 3224208XX,n,Set(__F=${UNIQUEID})
exten => 3224208XX,n,Set(__ODDZIAL=dep1)
exten => 3224208XX,n,Set(__DST=${EXTEN})
exten => 3224208XX,n,Background(zap_glowna2)
exten => 3224208XX,n,WaitExten(5)
exten => 3224208XX,n,Queue(salon_dep1,t,,20)
exten => 3224208XX,n,Hangup()

exten => _3276040XX,1,Answer()
exten => _3276040XX,n,GotoIfTime(19:00-7:00,mon-fri,*,*?zamkniete)
exten => _3276040XX,n,GotoIfTime(15:00-23:59,sat,*,*?zamkniete)
exten => _3276040XX,n,GotoIfTime(*,sun,*,*?zamkniete)
exten => _3276040XX,n,Set(__kolejka = "Zapowiedz glowna")
exten => _3276040XX,n,Set(__F=${UNIQUEID})
exten => _3276040XX,n,Set(__ODDZIAL=dep1)
exten => _3276040XX,n,Set(__DST=${EXTEN})

exten => _3276040XX,n,Background(zap_glowna2)
exten => _3276040XX,n,WaitExten(5)
exten => _3276040XX,n,Queue(salon_dep1,t)
exten => _3276040XX,n,Hangup()
exten => _3276040XX,n(zamkniete),Goto(zamkniete,${EXTEN},1)

exten => 1,1,GotoIf($["${ODDZIAL}" = "dep2"]?dep21:dep11)
exten => 1,n(dep21),Set(__kolejka="Serwis dep2")
exten => 1,n(dep21),Queue(${SERWIS_DEP2},t)
exten => 1,n(dep11),Set(__kolejka="Serwis dep1")
exten => 1,n(dep11),Queue(${SERWIS_dep1},t)

exten => 2,1,GotoIf($["${ODDZIAL}" = "dep2"]?dep22:dep12)
exten => 2,n(dep22),Set(__kolejka="Salon dep2")
exten => 2,n(dep22),Queue(${SALON_DEP2},t)
exten => 2,n(dep12),Set(__kolejka="Salon dep1")
exten => 2,n(dep12),Queue(${SALON_dep1},t)

exten => 3,1,Set(__kolejka="Flota")
exten => 3,n,Queue(${FLOTA},t)

exten => 4,1,Set(__kolejka="Komis")
exten => 4,n,Queue(${KOMIS},t)

exten => 5,1,GotoIf($["${ODDZIAL}" = "dep2"]?dep25:dep15)
exten => 5,n(dep25),Set(__kolejka="Czesci i akcesoria dep2")
exten => 5,n(dep25),Queue(${SKLEP_DEP2},t)
exten => 5,n(dep15),Set(__kolejka="Czesci i akcesoria dep1")
exten => 5,n(dep15),Queue(${SKLEP_dep1},t)

exten => 6,1,Set(__kolejka="Blacharnia")
exten => 6,n,Queue(${BLACHARNIA},t)

exten => 7,1,GotoIf($["${ODDZIAL}" = "dep2"]?dep27:dep17)
exten => 7,n(dep27),Set(__kolejka="Ubezpieczenia dep2")
exten => 7,n(dep27),Queue(${UBEZP_DEP2},t)
exten => 7,n(dep17),Set(__kolejka="Ubezpieczenia dep1")
exten => 7,n(dep17),Queue(${UBEZP_dep1},t)

exten => 8,1,Set(__kolejka="SKP")
exten => 8,n,Queue(${SKP},t)

exten => 9,1,Set(__kolejka="Ksiegowosc i windykacja")
exten => 9,n,Queue(${KSIEGOWOSC},t)

exten => _XXX,1,Set(__kolejka="Wybor wewn.: ${EXTEN}")
exten => _XXX,n,Dial(Local/${EXTEN}@wew/n)

[macro-tryb_a]
exten => s,1,Set(GLOBAL(SERWIS_dep1)=bdc)
exten => s,n,Set(GLOBAL(SERWIS_DEP2)=bdc)
exten => s,n,Set(GLOBAL(SALON_dep1)=bdc)
exten => s,n,Set(GLOBAL(SALON_DEP2)=bdc)
exten => s,n,Set(GLOBAL(FLOTA)=bdc)
exten => s,n,Set(GLOBAL(KOMIS)=bdc)
exten => s,n,Set(GLOBAL(SKLEP_dep1)=sklep_dep1)
exten => s,n,Set(GLOBAL(SKLEP_DEP2)=sklep_DEP2)
exten => s,n,Set(GLOBAL(BLACHARNIA)=bdc)
exten => s,n,Set(GLOBAL(UBEZP_dep1)=bdc)
exten => s,n,Set(GLOBAL(UBEZP_DEP2)=bdc)
exten => s,n,Set(GLOBAL(KSIEGOWOSC)=ksiegowosc)
exten => s,n,Set(GLOBAL(SKP)=bdc)
exten => s,n,Set(GLOBAL(TRYB)=a)
exten => s,n,SayPhonetic(a)
exten => s,n,Hangup()

[macro-tryb_b]
exten => s,1,Set(GLOBAL(KSIEGOWOSC)=ksiegowosc)
exten => s,n,Set(GLOBAL(SERWIS_dep1)=serwis_dep1)
exten => s,n,Set(GLOBAL(SERWIS_DEP2)=serwis_DEP2)
exten => s,n,Set(GLOBAL(SALON_dep1)=salon_dep1)
exten => s,n,Set(GLOBAL(SALON_DEP2)=salon_DEP2)
exten => s,n,Set(GLOBAL(FLOTA)=flota)
exten => s,n,Set(GLOBAL(KOMIS)=komis)
exten => s,n,Set(GLOBAL(SKLEP_dep1)=sklep_dep1)
exten => s,n,Set(GLOBAL(SKLEP_DEP2)=sklep_DEP2)
exten => s,n,Set(GLOBAL(BLACHARNIA)=blacharnia)
exten => s,n,Set(GLOBAL(UBEZP_dep1)=ubezp_dep1)
exten => s,n,Set(GLOBAL(UBEZP_DEP2)=ubezp_DEP2)
exten => s,n,Set(GLOBAL(SKP)=skp)
exten => s,n,Set(GLOBAL(KSIEGOWOSC)=ksiegowosc)

exten => s,n,Set(GLOBAL(TRYB)=b)
exten => s,n,SayPhonetic(b)
exten => s,n,Hangup()

[macro-dodaj]
exten => s,1,AddQueueMember(bdc,Local/${Arg1}@wew/n)
exten => s,n,Playback(agent-loginok)
exten => s,n,Hangup

[macro-usun]
exten => s,1,RemoveQueueMember(bdc,Local/${Arg1}@wew/n)
exten => s,n,Playback(agent-loggedoff)
exten => s,n,Hangup()
	
[test]
exten => s,1,Answer()
exten => s,n,Set(ODBC_REJ_FASTZILLA(${CALLERID(name)}${CALLERID(number)},${EXTEN},${UNIQUEID})=0)
exten => s,n,Dial(SIP/51,25,t)

[from-dwg]
exten => s,1,NoOp(DWG CHANNEL: ${CHANNEL}, DWG EXT: ${EXTEN})
exten => s,n,Answer()

exten => 571XXX773,1,Set(__ODDZIAL="dep1")
exten => 571XXX773,n,Set(__DST=${EXTEN})
exten => 571XXX773,n,Set(__CLID=${CUT(SIP_HEADER(From),\ ,-1)})
exten => 571XXX773,n,Set(__F=${UNIQUEID})
exten => 571XXX773,n,Set(__kolejka="Oddzwania na 107: ${EXTEN}")
exten => 571XXX773,n,ChanIsAvail(Local/107@wew)
exten => 571XXX773,n,Dial(Local/107@wew/n)
exten => 571XXX773,n,Queue(bdc,t)

exten => 571XXX774,1,Set(__ODDZIAL="dep1")
exten => 571XXX774,n,Set(__DST=${EXTEN})
exten => 571XXX774,n,Set(__CLID=${CUT(SIP_HEADER(From),\ ,-1)})
exten => 571XXX774,n,Set(__F=${UNIQUEID})
exten => 571XXX774,n,Set(__kolejka="Oddzwania na 104: ${EXTEN}")
exten => 571XXX774,n,Dial(Local/104@wew/n)
exten => 571XXX774,n,Queue(bdc,t)

exten => 571XXX775,1,Set(__ODDZIAL="dep1")
exten => 571XXX775,n,Set(__CLID=${CUT(SIP_HEADER(From),\ ,-1)})
exten => 571XXX775,n,Set(__DST=${EXTEN})
exten => 571XXX775,n,Set(__F=${UNIQUEID})
exten => 571XXX775,n,Set(__kolejka="Oddzwania na 105: ${EXTEN}")
exten => 571XXX775,n,Dial(Local/105@wew/n)
exten => 571XXX775,n,Queue(bdc,t)

exten => XXXXXXXXX,1,Set(__ODDZIAL="dep1")
exten => XXXXXXXXX,n,Set(__CLID=${CUT(SIP_HEADER(From),\ ,-1)})
exten => XXXXXXXXX,n,Set(__DST=${EXTEN})
exten => XXXXXXXXX,n,Set(__F=${UNIQUEID})
exten => XXXXXXXXX,n,Set(__kolejka="WejscieGSM: ${EXTEN}")
exten => XXXXXXXXX,n,Goto(from-pstn,327XXXXXX,1)
exten => XXXXXXXXX,n,Queue(bdc,t)


exten => grupa,1,Set(__CLID=${CUT(SIP_HEADER(From),\ ,-1)})
exten => grupa,n,Set(__ODDZIAL="dep1")
exten => grupa,n,Set(__DST=${EXTEN})
exten => grupa,n,Set(__F=${UNIQUEID})
exten => grupa,n,Set(__kolejka="WejscieGSM")
exten => grupa,n,Goto(from-pstn,327XXXXXX,1)

And some documentation on how it is supposed to work.

Alternatively, can you produce a simplified example.

I’ll skip the part with ODBC and other not important elements.

Context [wew] is for internal conversations and [macro-zadzwon] for dial extension. Context [tran] for transfers.

[wew] ;(main part)
exten => _XXX,1,Set(__TRANSFER_CONTEXT=tran)
exten => _XXX,n,Set(__ZEW_NUM=${CALLERID(number)})
exten => _XXX,n,Macro(zadzwon,${EXTEN})

[macro-zadzwon] ;(main part)
exten => s,1,Set(GROUP()=${ARG1}-calls)
exten => s,n,GotoIf($[${GROUP_COUNT(${ARG1}-calls)} > 1]?busy)
exten => s,n,ExecIf($["${AVAILCHAN:0:3}"=“SIP”]?Dial(SIP/${ARG1},40,TtRr):Hangup())
exten => s,n(busy),Busy(10)
exten => s,n,Hangup

[tran] ;(main part)
;transfer context
exten => _XXX,1,Set(_TransToExt=${EXTEN})
exten => _XXX,n,Set(__F=${IF(${ISNULL(${F})}=0?${UNIQUEID}:${F})})
exten => _XXX,n,NoOp(**************************IN TRANSFER ${TransToExt})
exten => _XXX,n,Set(CALLERID(num)=${ZEW_NUM})
exten => _XXX,n,Macro(zadzwon,${EXTEN})
exten => h,1… some ODBC stuff
exten => h,n…
exten => h,n,Hangup()

—edit----
this is after transfer was completed.

  1. 501320353 -> 901
  2. 901 -> 902
  3. 501320353 -> 902 (901 has state ringing)

steel*CLI> core show channels
Channel Location State Application(Data)
DAHDI/i1/501320353-3 901@from-pstn:2 Up Dial(Local/901@wew/n)
Local/902@tran-00000 s@macro-zadzwon:33 Up Dial(SIP/902,40,TtRr)
Local/902@tran-00000 902@tran:1 Up Transferred Call(Local/901@wew
SIP/902-000002f3 (None) Up AppDial((Outgoing Line))
Local/901@wew-000000 902@tran:1 Up Transferred Call(Local/902@tra
Local/901@wew-000000 (None) Ringing AppDial((Outgoing Line))

You haven’t included the from-pstn context, or explained why it is using a local channel.

SOLVED

Thank you,

I had exten => _XXX,n,Dial(Local/${EXTEN}@wew/n) in my [FROM-PSTN].
I changed to exten => _XXX,n,Macro(zadzwon,${EXTEN}).

It still executes hangup for 901 and 902 together after 902 disconnects but it doesn’t keep 901 busy after transfer.