Answering my own question, parking the call with "uuid_transfer <uuid> -both 'park' inline" first keeps the other leg busy and things won't hang up.

-Anders

On Wed, Mar 3, 2010 at 4:53 PM, Anders Brownworth <abrownworth@bandwidth.com> wrote:
Hello fellow FreeSWITCH users,

I'm using FreeSWITCH Version 1.0.trunk (16883) and I'm using the event socket to break an in-progress call into two independently controlled legs. I want to be able to work with each leg completely independently - hanging up one without affecting the other. Per the docs: http://wiki.freeswitch.org/wiki/Mod_commands#uuid_transfer I'm using uuid_transfer with an inline lua script to work with one leg without hanging up on the other. I'm setting "hangup_after_bridge" to false on both channels and invoking uuid_transfer with the -bleg option but as soon as I transfer, FreeSWITCH hangs up on one of the legs.

Here's what I'm sending on the event socket. (everything gets an "OK" response from FreeSWITCH)

Set hangup_after_bridge:


api uuid_setvar 53d37581-1f90-44bf-860a-addbc8430e3a hangup_after_bridge false
api uuid_setvar 9d1a4f2d-2ce6-40e5-ac84-62ad8c2d4654 hangup_after_bridge false

And then do the uuid_transfer:

api uuid_transfer 53d37581-1f90-44bf-860a-addbc8430e3a -bleg 'lua:callee.lua' inline
api uuid_transfer 9d1a4f2d-2ce6-40e5-ac84-62ad8c2d4654 -bleg 'lua:caller.lua' inline

The callee leg (53d37581-1f90-44bf-860a-addbc8430e3a) is immediately hung up and the caller leg runs fine. Here's the log messages: (6505551212 is the caller and 5165551212 is the callee)

2010-03-03 21:29:56.086319 [DEBUG] switch_ivr.c:1441 (sofia/external/+16505551212@192.168.27.72) State Change CS_EXECUTE -> CS_ROUTING
2010-03-03 21:29:56.086319 [DEBUG] switch_core_session.c:1018 Send signal sofia/external/+16505551212@192.168.27.72 [BREAK]
2010-03-03 21:29:56.086319 [DEBUG] switch_core_session.c:638 Send signal sofia/external/+16505551212@192.168.27.72 [BREAK]
2010-03-03 21:29:56.086319 [NOTICE] switch_ivr.c:1447 Transfer sofia/external/+16505551212@192.168.27.72 to inline[lua:callee.lua@public]
2010-03-03 21:29:56.092461 [DEBUG] switch_core_session.c:638 Send signal sofia/external/+16505551212@192.168.27.72 [BREAK]
2010-03-03 21:29:56.092461 [DEBUG] switch_ivr_bridge.c:565 BRIDGE THREAD DONE [sofia/external/+16505551212@192.168.27.72]
2010-03-03 21:29:56.092461 [DEBUG] switch_ivr_bridge.c:585 Send signal sofia/external/+15165551212 [BREAK]
2010-03-03 21:29:56.092461 [DEBUG] switch_rtp.c:1626 Send middle packet for [1] ts=91040 dur=1760/1760/2440 seq=7493
2010-03-03 21:29:56.092461 [DEBUG] switch_core_session.c:638 Send signal sofia/external/+15165551212 [BREAK]
2010-03-03 21:29:56.092461 [DEBUG] switch_ivr_bridge.c:565 BRIDGE THREAD DONE [sofia/external/+15165551212]
2010-03-03 21:29:56.092461 [DEBUG] switch_ivr_bridge.c:585 Send signal sofia/external/+16505551212@192.168.27.72 [BREAK]
2010-03-03 21:29:56.092461 [NOTICE] switch_ivr_bridge.c:637 Hangup sofia/external/+15165551212 [CS_EXCHANGE_MEDIA] [NORMAL_CLEARING]
2010-03-03 21:29:56.092461 [DEBUG] switch_channel.c:2071 Send signal sofia/external/+15165551212 [KILL]
2010-03-03 21:29:56.092461 [DEBUG] switch_core_session.c:1018 Send signal sofia/external/+15165551212 [BREAK]
2010-03-03 21:29:56.092461 [DEBUG] switch_core_state_machine.c:351 (sofia/external/+15165551212) State EXCHANGE_MEDIA going to sleep
2010-03-03 21:29:56.092461 [DEBUG] switch_core_state_machine.c:314 (sofia/external/+15165551212) Running State Change CS_HANGUP
2010-03-03 21:29:56.092461 [DEBUG] switch_core_state_machine.c:499 (sofia/external/+15165551212) State HANGUP
2010-03-03 21:29:56.092461 [DEBUG] mod_sofia.c:411 Channel sofia/external/+15165551212 hanging up, cause: NORMAL_CLEARING
2010-03-03 21:29:56.092461 [DEBUG] mod_sofia.c:454 Sending BYE to sofia/external/+15165551212
2010-03-03 21:29:56.092461 [DEBUG] switch_core_state_machine.c:46 sofia/external/+15165551212 Standard HANGUP, cause: NORMAL_CLEARING
2010-03-03 21:29:56.092461 [DEBUG] switch_core_state_machine.c:499 (sofia/external/+15165551212) State HANGUP going to sleep
2010-03-03 21:29:56.092461 [DEBUG] switch_core_state_machine.c:333 (sofia/external/+15165551212) State Change CS_HANGUP -> CS_REPORTING
2010-03-03 21:29:56.092461 [DEBUG] switch_core_session.c:1018 Send signal sofia/external/+15165551212 [BREAK]
2010-03-03 21:29:56.092461 [DEBUG] switch_core_state_machine.c:314 (sofia/external/+15165551212) Running State Change CS_REPORTING
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:590 (sofia/external/+15165551212) State REPORTING
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:348 (sofia/external/+16505551212@192.168.27.72) State EXECUTE going to sleep
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:314 (sofia/external/+16505551212@192.168.27.72) Running State Change CS_ROUTING
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:341 (sofia/external/+16505551212@192.168.27.72) State ROUTING
2010-03-03 21:29:56.093481 [DEBUG] mod_sofia.c:140 sofia/external/+16505551212@192.168.27.72 SOFIA ROUTING
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:77 sofia/external/+16505551212@192.168.27.72 Standard ROUTING
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:119 (sofia/external/+16505551212@192.168.27.72) State Change CS_ROUTING -> CS_EXECUTE
2010-03-03 21:29:56.093481 [DEBUG] switch_core_session.c:1018 Send signal sofia/external/+16505551212@192.168.27.72 [BREAK]
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:341 (sofia/external/+16505551212@192.168.27.72) State ROUTING going to sleep
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:314 (sofia/external/+16505551212@192.168.27.72) Running State Change CS_EXECUTE
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:348 (sofia/external/+16505551212@192.168.27.72) State EXECUTE
2010-03-03 21:29:56.093481 [DEBUG] mod_sofia.c:226 sofia/external/+16505551212@192.168.27.72 SOFIA EXECUTE
2010-03-03 21:29:56.093481 [DEBUG] switch_core_state_machine.c:157 sofia/external/+16505551212@192.168.27.72 Standard EXECUTE
EXECUTE sofia/external/+16505551212@192.168.27.72 lua(callee.lua)
2010-03-03 21:29:56.095544 [DEBUG] switch_core_state_machine.c:53 sofia/external/+15165551212 Standard REPORTING, cause: NORMAL_CLEARING
2010-03-03 21:29:56.095544 [DEBUG] switch_core_state_machine.c:590 (sofia/external/+15165551212) State REPORTING going to sleep
2010-03-03 21:29:56.095544 [DEBUG] switch_core_state_machine.c:327 (sofia/external/+15165551212) State Change CS_REPORTING -> CS_DESTROY
2010-03-03 21:29:56.095544 [DEBUG] switch_core_session.c:1018 Send signal sofia/external/+15165551212 [BREAK]
2010-03-03 21:29:56.095544 [DEBUG] switch_core_session.c:1161 Session 24 (sofia/external/+15165551212) Locked, Waiting on external entities
2010-03-03 21:29:56.095544 [NOTICE] switch_core_session.c:1179 Session 24 (sofia/external/+15165551212) Ended
2010-03-03 21:29:56.095544 [NOTICE] switch_core_session.c:1181 Close Channel sofia/external/+15165551212 [CS_DESTROY]
2010-03-03 21:29:56.095544 [DEBUG] switch_core_state_machine.c:428 (sofia/external/+15165551212) Running State Change CS_DESTROY
2010-03-03 21:29:56.095544 [DEBUG] switch_core_state_machine.c:439 (sofia/external/+15165551212) State DESTROY
2010-03-03 21:29:56.095544 [DEBUG] mod_sofia.c:338 sofia/external/+15165551212 SOFIA DESTROY
2010-03-03 21:29:56.095544 [DEBUG] switch_core_state_machine.c:60 sofia/external/+15165551212 Standard DESTROY
2010-03-03 21:29:56.095544 [DEBUG] switch_core_state_machine.c:439 (sofia/external/+15165551212) State DESTROY going to sleep
2010-03-03 21:29:56.127189 [DEBUG] switch_ivr.c:1441 (sofia/external/+16505551212@192.168.27.72) State Change CS_EXECUTE -> CS_ROUTING
2010-03-03 21:29:56.127189 [DEBUG] switch_core_session.c:1018 Send signal sofia/external/+16505551212@192.168.27.72 [BREAK]
2010-03-03 21:29:56.127189 [DEBUG] switch_core_session.c:638 Send signal sofia/external/+16505551212@192.168.27.72 [BREAK]
2010-03-03 21:29:56.127189 [NOTICE] switch_ivr.c:1447 Transfer sofia/external/+16505551212@192.168.27.72 to inline[lua:caller.lua]
2010-03-03 21:29:56.875077 [DEBUG] switch_core_media_bug.c:360 Attaching BUG to sofia/external/+16505551212@192.168.27.72
2010-03-03 21:29:56.909780 [DEBUG] switch_core_media_bug.c:442 Removing BUG from sofia/external/+16505551212@192.168.27.72
2010-03-03 21:29:56.910802 [ERR] inline:1  Session is not active!
2010-03-03 21:29:56.910802 [DEBUG] switch_core_state_machine.c:348 (sofia/external/+16505551212@192.168.27.72) State EXECUTE going to sleep
2010-03-03 21:29:56.910802 [DEBUG] switch_core_state_machine.c:314 (sofia/external/+16505551212@192.168.27.72) Running State Change CS_ROUTING
2010-03-03 21:29:56.910802 [DEBUG] switch_core_state_machine.c:341 (sofia/external/+16505551212@192.168.27.72) State ROUTING
2010-03-03 21:29:56.910802 [DEBUG] mod_sofia.c:140 sofia/external/+16505551212@192.168.27.72 SOFIA ROUTING
2010-03-03 21:29:56.910802 [DEBUG] switch_core_state_machine.c:77 sofia/external/+16505551212@192.168.27.72 Standard ROUTING
2010-03-03 21:29:56.910802 [DEBUG] switch_core_state_machine.c:119 (sofia/external/+16505551212@192.168.27.72) State Change CS_ROUTING -> CS_EXECUTE
2010-03-03 21:29:56.910802 [DEBUG] switch_core_session.c:1018 Send signal sofia/external/+16505551212@192.168.27.72 [BREAK]
2010-03-03 21:29:56.910802 [DEBUG] switch_core_state_machine.c:341 (sofia/external/+16505551212@192.168.27.72) State ROUTING going to sleep
2010-03-03 21:29:56.910802 [DEBUG] switch_core_state_machine.c:314 (sofia/external/+16505551212@192.168.27.72) Running State Change CS_EXECUTE
2010-03-03 21:29:56.910802 [DEBUG] switch_core_state_machine.c:348 (sofia/external/+16505551212@192.168.27.72) State EXECUTE
2010-03-03 21:29:56.910802 [DEBUG] mod_sofia.c:226 sofia/external/+16505551212@192.168.27.72 SOFIA EXECUTE
2010-03-03 21:29:56.910802 [DEBUG] switch_core_state_machine.c:157 sofia/external/+16505551212@192.168.27.72 Standard EXECUTE
EXECUTE sofia/external/+16505551212@192.168.27.72 lua(caller.lua)
2010-03-03 21:29:56.911830 [NOTICE] switch_cpp.cpp:1142 *********** Caller.lua - Success: 53d37581-1f90-44bf-860a-addbc8430e3a ***********
2010-03-03 21:29:56.911830 [ERR] switch_core_session.c:357 Could not locate channel type 53d37581-1f90-44bf-860a-addbc8430e3a
2010-03-03 21:29:56.911830 [ERR] switch_ivr_originate.c:2389 Cannot create outgoing channel of type [53d37581-1f90-44bf-860a-addbc8430e3a] cause: [CHAN_NOT_IMPLEMENTED]
2010-03-03 21:29:56.911830 [DEBUG] switch_ivr_originate.c:3187 Originate Resulted in Error Cause: 66 [CHAN_NOT_IMPLEMENTED]
2010-03-03 21:29:56.911830 [ERR] switch_cpp.cpp:618 session is not initalized
2010-03-03 21:29:57.032095 [DEBUG] switch_ivr_play_say.c:1156 Codec Activated L16@8000hz 1 channels 20ms

How can I get the callee leg to stay up? Is this not what -bleg is supposed to do? Am I doing something wrong here? I've tried parking both legs and invoking the lua on the channels but one of the channels still drops and the uuid is no-longer available in the event socket.

Is there some other preferred way to split a call apart?

Thanks.

-Anders