Originate command problem (connect external number with Ring Group)

There is a strange problem:
I try to initiate a call which will connect external number (at the first leg) and ring group (in the second leg).
Originate(“Local/[email protected]”,510,from-click2dial-ext,1,’’,’’,60,’’,’’,’’,true)

First leg work fine - I receive a call and answer it but then receive the following log:

– Executing [[email protected]:15] Macro(“Local/[email protected];1”, “dial,60,m(default)t,501-502-503-504-506-507-508-509”) in new stack
– Executing [[email protected]:1] GotoIf(“Local/[email protected];1”, “1?dial”) in new stack
– Goto (macro-dial,s,3)
– Executing [[email protected]:3] AGI(“Local/[email protected];1”, “dialparties.agi”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/dialparties.agi
<Local/[email protected];1>AGI Tx >> agi_request: dialparties.agi
<Local/[email protected];1>AGI Tx >> agi_channel: Local/[email protected];1
<Local/[email protected];1>AGI Tx >> agi_language: it
<Local/[email protected];1>AGI Tx >> agi_type: Local
<Local/[email protected];1>AGI Tx >> agi_uniqueid: 1353261975.14542
<Local/[email protected];1>AGI Tx >> agi_version: 1.8.13.0
<Local/[email protected];1>AGI Tx >> agi_callerid: unknown
<Local/[email protected];1>AGI Tx >> agi_calleridname: RG:
<Local/[email protected];1>AGI Tx >> agi_callingpres: 0
<Local/[email protected];1>AGI Tx >> agi_callingani2: 0
<Local/[email protected];1>AGI Tx >> agi_callington: 0
<Local/[email protected];1>AGI Tx >> agi_callingtns: 0
<Local/[email protected];1>AGI Tx >> agi_dnid: unknown
<Local/[email protected];1>AGI Tx >> agi_rdnis: unknown
<Local/[email protected];1>AGI Tx >> agi_context: macro-dial
<Local/[email protected];1>AGI Tx >> agi_extension: s
<Local/[email protected];1>AGI Tx >> agi_priority: 3
<Local/[email protected];1>AGI Tx >> agi_enhanced: 0.0
<Local/[email protected];1>AGI Tx >> agi_accountcode:
<Local/[email protected];1>AGI Tx >> agi_threadid: 1083906368
<Local/[email protected];1>AGI Tx >>
– Executing [[email protected]:1] Macro(“Local/[email protected];2”, “hangupcall,”) in new stack
– Executing [[email protected]:1] GotoIf(“Local/[email protected];2”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,3)
– Executing [[email protected]:3] ExecIf(“Local/[email protected];2”, “0?Set(CDR(recordingfile)=)”) in new stack
– Executing [[email protected]:4] Hangup(“Local/[email protected];2”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘Local/[email protected];2’ in macro ‘hangupcall’
== Spawn extension (macro-dialout-trunk, h, 1) exited non-zero on ‘Local/[email protected];2’
== Spawn extension (macro-dialout-trunk, s, 22) exited non-zero on ‘Local/[email protected];2’ in macro ‘dialout-trunk’
== Spawn extension (from-internal, 078478223, 5) exited non-zero on ‘Local/[email protected];2’
<SIP/37379-00000706>AGI Rx << VERBOSE “Starting New Dialparties.agi” 1
dialparties.agi: Starting New Dialparties.agi
<SIP/37379-00000706>AGI Tx >> 200 result=1
<SIP/37379-00000706>AGI Rx << GET VARIABLE CWINUSEBUSY
<SIP/37379-00000706>AGI Tx >> 200 result=1 (true)
<SIP/37379-00000706>AGI Rx << GET VARIABLE ASTVERSION
<SIP/37379-00000706>AGI Tx >> 200 result=1 (1.8.13.0)
<SIP/37379-00000706>AGI Rx << GET VARIABLE ASTCHANDAHDI
<SIP/37379-00000706>AGI Tx >> 200 result=1 (1)
<SIP/37379-00000706>AGI Rx << GET VARIABLE CWIGNORE
<SIP/37379-00000706>AGI Tx >> 200 result=1 (TRUE)
<SIP/37379-00000706>AGI Rx << GET VARIABLE CFIGNORE
<SIP/37379-00000706>AGI Tx >> 200 result=1 (TRUE)
<SIP/37379-00000706>AGI Rx << GET VARIABLE HAS_EXTENSION_STATE
<SIP/37379-00000706>AGI Tx >> 200 result=0
<SIP/37379-00000706>AGI Rx << VERBOSE “Caller ID name is ‘RG:’ number is ‘unknown’” 1
dialparties.agi: Caller ID name is ‘RG:’ number is ‘unknown’
<SIP/37379-00000706>AGI Tx >> 200 result=1
<SIP/37379-00000706>AGI Rx << GET VARIABLE QUEUEWAIT
<SIP/37379-00000706>AGI Tx >> 200 result=0
<SIP/37379-00000706>AGI Rx << SET VARIABLE __KEEPCID “TRUE”
<SIP/37379-00000706>AGI Tx >> 200 result=1
<SIP/37379-00000706>AGI Rx << SET VARIABLE DIALSTATUS_CW “”
<SIP/37379-00000706>AGI Tx >> 200 result=1
<SIP/37379-00000706>AGI Rx << GET VARIABLE ARG1
<SIP/37379-00000706>AGI Tx >> 200 result=0
<SIP/37379-00000706>AGI Rx << GET VARIABLE ARG2
<SIP/37379-00000706>AGI Tx >> 200 result=0

So you see that by some reason just after dialparties.agi start the first leg get hangup. And by some reason in the second leg dialparties.agi start their work within different channel.

[from-click2dial]
exten => _.,1,Goto(from-internal,${EXTEN},1())
exten => h,1,Set(CDR(userfield)=${CONNECTEDLINE(num,i)})
exten => h,n,Macro(hangupcall,)

[from-click2dial-ext]
exten => _.,1,Goto(ext-group,510,1)