david
2009-Feb-25 03:14 UTC
[asterisk-users] Problem redirecting user running a Dynamic feature
Hello, Here is my setup : Telephone 1 ( GXP 2000 ) Telephone 2 ( SPA942 ) Asterisk 1.4.17 ( same behaviour on Asterisk 1.4.23.1 ) Scenario: I don't like the default asterisk transfer feature, so I am trying to write my own. What I did : 1. Added to dynamic features #3 with AGI pointing to my php script 2. PHP script asks the user to enter his/her extension 3. PHP connects to Asterisk Manager and sends a redirect command on the other channel 4. PHP tells user the call has been transfered and wishes the user a good day. 5. Script ends. What should happen : 1. Telephone1 calls telephone2 2. Telephone2 enters #3 3. Telephone1 hears on hold music and Telephone2 enters the new extension 4. PHP calls Asterisk Manager to transfer Telephone1 to the new extension 5. Telephone2 hears a message wishing the user a good day 6. Telephone2 hangup What actually happens : 1. Ok 2. Ok 3. Ok 4. PHP calls Asterisk Manager to transfer Telephone1, but Telephone one does not transfer it just has dead air 5. Telephone2 hears a message wishing the user a good day 6. Telephone2 hangs up 7. Telephone1 disconnects 8. Telephone1 ( according to asterisk ) completes the transfer the the new extension 9. Asterisk plays a file, realises that Telephone1 is gone and disconnects. Here is part of the logs : telephone2 = 081c5350 telephone1 = 081bfe98 I am transfering the caller to extension 860809864 in default context =================================== -- Called telephone2 at voip.myserver.tld -- SIP/voip.myserver.tld-081c5350 is ringing -- SIP/voip.myserver.tld-081c5350 answered SIP/voip.myserver.tld-081bfe98 -- Feature Found: df3 exten: df3 -- Launched AGI Script /opt/customTransfer.php == Parsing '/etc/asterisk/manager.conf': Found == Parsing '/etc/asterisk/manager.d/blank.conf': Found == Manager 'theking' logged on from 127.0.0.1 -- PHP Log : Sending to SIP/voip.myserver.tld-081bfe98 to 860809864 == Manager 'theking' logged off from 127.0.0.1 -- AGI Script /opt/customTransfer.php completed, returning 0 == Spawn extension (default, 860809864, 0) exited non-zero on 'SIP/voip.myserver.tld-081bfe98' -- Executing [860809864 at default:1] NoOp("SIP/voip.myserver.tld-081bfe98", "Receiving call to 860809864") in new stack -- Executing [860809864 at default:2] Set("SIP/voip.myserver.tld-081bfe98", "__TRANSFER_CONTEXT=default") in new stack -- Executing [860809864 at default:3] AGI("SIP/voip.myserver.tld-081bfe98", "/opt/itworks.php") in new stack -- Launched AGI Script /opt/itworks.php == Spawn extension (default, 860809864, 3) exited non-zero on 'SIP/voip.myserver.tld-081bfe98' cain*CLI> ======================================== If I run the customTransfer.php in bash while the telephone is NOT in dynamic features, it works perfectly. It seems like that if telephone1 is held while telephone 2 is in a dynamic feature, the redirect fails. Additionally, if I do it backwards and the calling user transfers the called user using #3, it works perfectly without any problems. What have I done wrong ? Is there a better way to implement a custom transfer feature? Thanks, David