[Freeswitch-dev] bridging calls using mod_managed
Hi, I've been working with FS for some time now, and are progressing. I am working on a platform (in/ivr) which is handled by .net managed code completely. I am using just 1 application which is always launched on incomming calls. This application immedeately connects with my MSSQL server and checks validity of gateways, inbound number etc. Also a cdr is written and updated periodically while the call is active. I have als set the HandleHangUp handler to finalize the cdr and call when the calller disconnects. This whole mechanism works as a charm. This application then plays voicefiles, getdigits, and everything as I would expect. Hoewever at some point I want to dialout to an external number and connect these two calls together. I do not want to leave the originating .net app as long as my incomming caller is still online (to update the cdr and finalize the call). While these two are connected I need to update my database periodicaly (keepalive). I have been looking the internet to find what I need but i can't get it to work 100%. In fact everything works, but when I bridge the two calls together it fails. I use the following and this whole peace of code actually works, it dials out, aborts when someone hangsup and when the b_leg picks up they both get audiofile turn by turn.... It even checks outbuond status and maps this to the original call. (so really acts like a switch). Debug("Got a route=>"+route+", Let the network play the ringtone..."); leg_a.Execute("ring_ready", ""); Debug("Creating the new session..."); ManagedSession leg_b = new ManagedSession("sofia/external/"+route); // route holds {destinationNumber}@{myExternalGateway} if (leg_b.Ready()) { Debug("Session_B ready!"); string fsuuid_b = leg_b.GetVariable("uuid"); Debug("Waiting for B-Leg to answer and A-Leg not to hangup..."); while (!leg_b.answered() && leg_a.Ready() ) { /* Ringing... */ } if (leg_b.answered()) { Debug("...B-Leg is answered"); AnswerCall(leg_a); while (!leg_a.answered()) { } Debug("...A-Leg is answered"); // ****** BRIDGE SHOULD BE HERE ****** Debug("As long as both legs are Ready(), we wait......"); while (leg_b.Ready() && leg_a.Ready()) { Play(leg_b, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED Play(leg_a, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED } Debug("There is one leg no longer ready..."); if (leg_a.Ready()) { Debug("Session A still ready..."); } else { Debug("Session A NO LONGER ready...");} if (leg_b.Ready()) { Debug("Session B still ready..."); } else { Debug("Session B NO LONGER ready...");} } else { Debug("A-Leg aborted while dialing..."); } if (leg_b.Ready()) { Debug("B-Leg still here, so hanging up B-Leg..."); leg_b.Hangup("NORMAL_CALL_CLEARING"); leg_b.destroy(); } } else { string obCause = leg_b.hangupCause(); leg_a.HangUp(obCause); Debug("Route failed with: "+obCause); } return true; Of course I need to bridge the two calls together so they can speak to each other.. I am trying to bridge the call at "// ****** BRIDGE SHOULD BE HERE ****** " like this: leg_a.sleep(1000, 0); string apiResult = fsApi.ExecuteString(string.Format("uuid_bridge {1} {0}", leg_a.GetUuid(), leg_b.GetUuid())); Debug("apiResult="+apiResult); The console log shows "+OK {guid of leg_a} but at the very same moment the incomming calls is beging hung up, (I can see the Debug message of my HandleHangUp() at exactly the as me time as the apiResult of the bridge. I have checked without bridge to check if codecs are the the same and they both are PCMU 8000. Please any help is appreciated! I have been trying to make this work for over a week now, but it won''t work. note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together... Best Regards, Mike.
Can you paste the debug log from FreeSWITCH when this happens? From: freeswitch-dev-bounces@lists.freeswitch.org [mailto:freeswitch-dev-bounces@lists.freeswitch.org] On Behalf Of Michael Lutz Sent: Wednesday, January 04, 2012 10:10 AM To: freeswitch-dev@lists.freeswitch.org Subject: [Freeswitch-dev] bridging calls using mod_managed Hi, I've been working with FS for some time now, and are progressing. I am working on a platform (in/ivr) which is handled by .net managed code completely. I am using just 1 application which is always launched on incomming calls. This application immedeately connects with my MSSQL server and checks validity of gateways, inbound number etc. Also a cdr is written and updated periodically while the call is active. I have als set the HandleHangUp handler to finalize the cdr and call when the calller disconnects. This whole mechanism works as a charm. This application then plays voicefiles, getdigits, and everything as I would expect. Hoewever at some point I want to dialout to an external number and connect these two calls together. I do not want to leave the originating .net app as long as my incomming caller is still online (to update the cdr and finalize the call). While these two are connected I need to update my database periodicaly (keepalive). I have been looking the internet to find what I need but i can't get it to work 100%. In fact everything works, but when I bridge the two calls together it fails. I use the following and this whole peace of code actually works, it dials out, aborts when someone hangsup and when the b_leg picks up they both get audiofile turn by turn.... It even checks outbuond status and maps this to the original call. (so really acts like a switch). Debug("Got a route=>"+route+", Let the network play the ringtone..."); leg_a.Execute("ring_ready", ""); Debug("Creating the new session..."); ManagedSession leg_b = new ManagedSession("sofia/external/"+route); // route holds {destinationNumber}@{myExternalGateway<mailto:%7bdestinationNumber%7d@%7bmyExternalGateway>} if (leg_b.Ready()) { Debug("Session_B ready!"); string fsuuid_b = leg_b.GetVariable("uuid"); Debug("Waiting for B-Leg to answer and A-Leg not to hangup..."); while (!leg_b.answered() && leg_a.Ready() ) { /* Ringing... */ } if (leg_b.answered()) { Debug("...B-Leg is answered"); AnswerCall(leg_a); while (!leg_a.answered()) { } Debug("...A-Leg is answered"); // ****** BRIDGE SHOULD BE HERE ****** Debug("As long as both legs are Ready(), we wait......"); while (leg_b.Ready() && leg_a.Ready()) { Play(leg_b, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED Play(leg_a, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED } Debug("There is one leg no longer ready..."); if (leg_a.Ready()) { Debug("Session A still ready..."); } else { Debug("Session A NO LONGER ready...");} if (leg_b.Ready()) { Debug("Session B still ready..."); } else { Debug("Session B NO LONGER ready...");} } else { Debug("A-Leg aborted while dialing..."); } if (leg_b.Ready()) { Debug("B-Leg still here, so hanging up B-Leg..."); leg_b.Hangup("NORMAL_CALL_CLEARING"); leg_b.destroy(); } } else { string obCause = leg_b.hangupCause(); leg_a.HangUp(obCause); Debug("Route failed with: "+obCause); } return true; Of course I need to bridge the two calls together so they can speak to each other.. I am trying to bridge the call at "// ****** BRIDGE SHOULD BE HERE ****** " like this: leg_a.sleep(1000, 0); string apiResult = fsApi.ExecuteString(string.Format("uuid_bridge {1} {0}", leg_a.GetUuid(), leg_b.GetUuid())); Debug("apiResult="+apiResult); The console log shows "+OK {guid of leg_a} but at the very same moment the incomming calls is beging hung up, (I can see the Debug message of my HandleHangUp() at exactly the as me time as the apiResult of the bridge. I have checked without bridge to check if codecs are the the same and they both are PCMU 8000. Please any help is appreciated! I have been trying to make this work for over a week now, but it won''t work. note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together... Best Regards, Mike.
Hi Michael, Here it is: 2012-01-04 19:25:09.900945 [ERR] switch_cpp.cpp:1227 =============> ...A-Leg is answered 2012-01-04 19:25:09.925947 [DEBUG] switch_core_session.c:875 Send signal sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} [BREAK] 2012-01-04 19:25:09.925947 [DEBUG] switch_core_session.c:875 Send signal sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} [BREAK] 2012-01-04 19:25:09.925947 [DEBUG] switch_core_session.c:875 Send signal sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} [BREAK] 2012-01-04 19:25:09.925947 [DEBUG] switch_core_session.c:875 Send signal sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} [BREAK] 2012-01-04 19:25:09.925947 [DEBUG] sofia.c:5494 Channel sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} entering state [completed][200] 2012-01-04 19:25:09.925947 [DEBUG] sofia.c:5494 Channel sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} entering state [ready][200] 2012-01-04 19:25:09.985953 [DEBUG] switch_core_session.c:875 Send signal sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} [BREAK] 2012-01-04 19:25:10.005955 [INFO] sofia.c:819 sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} Update Callee ID to "HW-MIKE-TC01" <{MyOriginatingNumber}> 2012-01-04 19:25:10.005955 [DEBUG] sofia.c:7276 dispatched freeswitch event for INFO 2012-01-04 19:25:10.125967 [DEBUG] switch_rtp.c:3204 Correct ip/port confirmed. 2012-01-04 19:25:10.906045 [INFO] switch_channel.c:2708 sofia/external/{MyDestinationNumber}@{MyDestinationGateway} Flipping CID from "" <{MyOutboundOriginatingNumber}> to "Outbound Call" <{MyDestinationNumber}> 2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:1613 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) State Change CS_SOFT_EXECUTE -> CS_HIBERNATE 2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:1180 Send signal sofia/external/{MyDestinationNumber}@{MyDestinationGateway} [BREAK] 2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:1615 ( sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway}) State Change CS_EXECUTE -> CS_HIBERNATE 2012-01-04 19:25:10.906045 [DEBUG] switch_cpp.cpp:1227 AppFunction is in hangupCallback. 2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============> HandleHangUp(); 2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============> Finalizing call in CDR table 2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:362 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) Running State Change CS_HIBERNATE 2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:432 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) State HIBERNATE 2012-01-04 19:25:10.906045 [DEBUG] mod_sofia.c:222 sofia/external/{MyDestinationNumber}@{MyDestinationGateway} SOFIA HIBERNATE 2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:749 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) State Change CS_HIBERNATE -> CS_RESET 2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:1180 Send signal sofia/external/{MyDestinationNumber}@{MyDestinationGateway} [BREAK] 2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:432 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) State HIBERNATE going to sleep 2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:362 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) Running State Change CS_RESET 2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:413 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) State RESET 2012-01-04 19:25:10.906045 [DEBUG] mod_sofia.c:166 sofia/external/{MyDestinationNumber}@{MyDestinationGateway} SOFIA RESET 2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:734 sofia/external/{MyDestinationNumber}@{MyDestinationGateway} CUSTOM RESET 2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:741 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) State Change CS_RESET -> CS_SOFT_EXECUTE 2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:1180 Send signal sofia/external/{MyDestinationNumber}@{MyDestinationGateway} [BREAK] 2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:413 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) State RESET going to sleep 2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:362 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) Running State Change CS_SOFT_EXECUTE 2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:423 ( sofia/external/{MyDestinationNumber}@{MyDestinationGateway}) State SOFT_EXECUTE 2012-01-04 19:25:10.906045 [DEBUG] mod_sofia.c:584 SOFIA SOFT_EXECUTE 2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:759 sofia/external/{MyDestinationNumber}@{MyDestinationGateway} CUSTOM SOFT_EXECUTE 2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:1180 Send signal sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} [BREAK] 2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:791 Send signal sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway} [BREAK] 2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:791 Send signal sofia/external/{MyDestinationNumber}@{MyDestinationGateway} [BREAK] 2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============> apiResult=+OK 29319eca-87df-437b-8e52-92a0427f12b2 2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============> As long as both legs are Ready(), we wait...... 2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============> There is one leg no longer ready... 2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============> Session A NO LONGER ready... 2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============> Session B still ready... this is done with this piece of code: private string simpleCall(string route, string orig, int timeout) { string obCause = "ERROR"; Debug("Creating the new session..."); ManagedSession leg_b = new ManagedSession("{ignore_early_media=true,origination_caller_id_number=" + orig + ",originate_timeout=20}sofia/external/"+route); if (leg_b.Ready()) { Debug("Session_B ready!"); string fsuuid_b = leg_b.GetVariable("uuid"); Debug("Waiting for B-Leg to answer and A-Leg not to hangup..."); while (!leg_b.answered() && leg_a.Ready() ) { /* Ringing... */ } if (leg_b.answered()) { Debug("...B-Leg is answered"); AnswerCall(leg_a); while (!leg_a.answered()) { } Debug("...A-Leg is answered"); leg_a.sleep(1000, 0); string apiResult = fsApi.ExecuteString(string.Format("uuid_bridge {1} {0}", leg_a.GetUuid(), leg_b.GetUuid())); Debug("apiResult="+apiResult); obCause = "SUCCESS"; Debug("As long as both legs are Ready(), we wait......"); while (leg_b.Ready() && leg_a.Ready()) { // Play(leg_b, "Test\\dir-no_matching_results.wav"); // Play(leg_a, "Test\\dir-no_matching_results.wav"); } Debug("There is one leg no longer ready..."); if (leg_a.Ready()) { Debug("Session A still ready..."); } else { Debug("Session A NO LONGER ready...");} if (leg_b.Ready()) { Debug("Session B still ready..."); } else { Debug("Session B NO LONGER ready...");} } else { Debug("A-Leg aborted while dialing..."); } if (leg_b.Ready()) { Debug("B-Leg still here, so hanging up B-Leg..."); leg_b.Hangup("NORMAL_CALL_CLEARING"); leg_b.destroy(); } } else { obCause = leg_b.hangupCause(); } Debug("SimpleCall() ended with: " + obCause); return obCause; } Thanks, Mike. 2012/1/4 Michael Giagnocavo <mgg@giagnocavo.net>
Can you paste the debug log from FreeSWITCH when this happens?****
** **
*From:* freeswitch-dev-bounces@lists.freeswitch.org [mailto: freeswitch-dev-bounces@lists.freeswitch.org] *On Behalf Of *Michael Lutz *Sent:* Wednesday, January 04, 2012 10:10 AM *To:* freeswitch-dev@lists.freeswitch.org *Subject:* [Freeswitch-dev] bridging calls using mod_managed****
** **
Hi, ****
I've been working with FS for some time now, and are progressing. I am working on a platform (in/ivr) which is handled by .net managed code completely. I am using just 1 application which is always launched on incomming calls. This application immedeately connects with my MSSQL server and checks validity of gateways, inbound number etc. Also a cdr is written and updated periodically while the call is active. I have als set the HandleHangUp handler to finalize the cdr and call when the calller disconnects. This whole mechanism works as a charm. This application then plays voicefiles, getdigits, and everything as I would expect. Hoewever at some point I want to dialout to an external number and connect these two calls together. I do not want to leave the originating .net app as long as my incomming caller is still online (to update the cdr and finalize the call). While these two are connected I need to update my database periodicaly (keepalive). I have been looking the internet to find what I need but i can't get it to work 100%. In fact everything works, but when I bridge the two calls together it fails.****
I use the following and this whole peace of code actually works, it dials out, aborts when someone hangsup and when the b_leg picks up they both get audiofile turn by turn.... It even checks outbuond status and maps this to the original call. (so really acts like a switch).****
Debug("Got a route=>"+route+", Let the network play the ringtone..."); leg_a.Execute("ring_ready", "");****
Debug("Creating the new session..."); ManagedSession leg_b = new ManagedSession("sofia/external/"+route); // route holds {destinationNumber}@{myExternalGateway} if (leg_b.Ready()) { Debug("Session_B ready!"); string fsuuid_b = leg_b.GetVariable("uuid");****
Debug("Waiting for B-Leg to answer and A-Leg not to hangup..."); while (!leg_b.answered() && leg_a.Ready() ) { /* Ringing... */ }****
if (leg_b.answered()) { Debug("...B-Leg is answered"); AnswerCall(leg_a); while (!leg_a.answered()) { } Debug("...A-Leg is answered");****
// ****** BRIDGE SHOULD BE HERE ****** ****
Debug("As long as both legs are Ready(), we wait......"); while (leg_b.Ready() && leg_a.Ready()) { Play(leg_b, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED Play(leg_a, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED }****
Debug("There is one leg no longer ready..."); if (leg_a.Ready()) { Debug("Session A still ready..."); } else { Debug("Session A NO LONGER ready...");} if (leg_b.Ready()) { Debug("Session B still ready..."); } else { Debug("Session B NO LONGER ready...");} } else { Debug("A-Leg aborted while dialing..."); }****
if (leg_b.Ready()) { Debug("B-Leg still here, so hanging up B-Leg..."); leg_b.Hangup("NORMAL_CALL_CLEARING"); leg_b.destroy(); } } else { string obCause = leg_b.hangupCause();****
leg_a.HangUp(obCause); Debug("Route failed with: "+obCause); } return true;****
Of course I need to bridge the two calls together so they can speak to each other.. I am trying to bridge the call at "// ****** BRIDGE SHOULD BE HERE ****** " like this:****
leg_a.sleep(1000, 0); string apiResult = fsApi.ExecuteString(string.Format("uuid_bridge {1} {0}", leg_a.GetUuid(), leg_b.GetUuid())); Debug("apiResult="+apiResult);****
The console log shows "+OK {guid of leg_a} ****
but at the very same moment the incomming calls is beging hung up, (I can see the Debug message of my HandleHangUp() at exactly the as me time as the apiResult of the bridge. I have checked without bridge to check if codecs are the the same and they both are PCMU 8000. Please any help is appreciated! I have been trying to make this work for over a week now, but it won''t work.****
note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together...****
****
Best Regards,****
Mike.****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Hi, Anyone here who can help me with this problem? I got really stuck on this one.. Thanks for helping!, Mike Op 4 jan. 2012 om 18:58 heeft Michael Giagnocavo <mgg@giagnocavo.net> het volgende geschreven:
Can you paste the debug log from FreeSWITCH when this happens?
From: freeswitch-dev-bounces@lists.freeswitch.org [mailto:freeswitch-dev-bounces@lists.freeswitch.org] On Behalf Of Michael Lutz Sent: Wednesday, January 04, 2012 10:10 AM To: freeswitch-dev@lists.freeswitch.org Subject: [Freeswitch-dev] bridging calls using mod_managed
Hi,
I've been working with FS for some time now, and are progressing. I am working on a platform (in/ivr) which is handled by .net managed code completely. I am using just 1 application which is always launched on incomming calls. This application immedeately connects with my MSSQL server and checks validity of gateways, inbound number etc. Also a cdr is written and updated periodically while the call is active. I have als set the HandleHangUp handler to finalize the cdr and call when the calller disconnects. This whole mechanism works as a charm. This application then plays voicefiles, getdigits, and everything as I would expect. Hoewever at some point I want to dialout to an external number and connect these two calls together. I do not want to leave the originating .net app as long as my incomming caller is still online (to update the cdr and finalize the call). While these two are connected I need to update my database periodicaly (keepalive). I have been looking the internet to find what I need but i can't get it to work 100%. In fact everything works, but when I bridge the two calls together it fails.
I use the following and this whole peace of code actually works, it dials out, aborts when someone hangsup and when the b_leg picks up they both get audiofile turn by turn.... It even checks outbuond status and maps this to the original call. (so really acts like a switch). Debug("Got a route=>"+route+", Let the network play the ringtone..."); leg_a.Execute("ring_ready", "");
Debug("Creating the new session..."); ManagedSession leg_b = new ManagedSession("sofia/external/"+route); // route holds {destinationNumber}@{myExternalGateway} if (leg_b.Ready()) { Debug("Session_B ready!"); string fsuuid_b = leg_b.GetVariable("uuid");
Debug("Waiting for B-Leg to answer and A-Leg not to hangup..."); while (!leg_b.answered() && leg_a.Ready() ) { /* Ringing... */ }
if (leg_b.answered()) { Debug("...B-Leg is answered"); AnswerCall(leg_a); while (!leg_a.answered()) { } Debug("...A-Leg is answered");
// ****** BRIDGE SHOULD BE HERE ******
Debug("As long as both legs are Ready(), we wait......"); while (leg_b.Ready() && leg_a.Ready()) { Play(leg_b, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED Play(leg_a, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED }
Debug("There is one leg no longer ready..."); if (leg_a.Ready()) { Debug("Session A still ready..."); } else { Debug("Session A NO LONGER ready...");} if (leg_b.Ready()) { Debug("Session B still ready..."); } else { Debug("Session B NO LONGER ready...");} } else { Debug("A-Leg aborted while dialing..."); }
if (leg_b.Ready()) { Debug("B-Leg still here, so hanging up B-Leg..."); leg_b.Hangup("NORMAL_CALL_CLEARING"); leg_b.destroy(); } } else { string obCause = leg_b.hangupCause();
leg_a.HangUp(obCause); Debug("Route failed with: "+obCause); } return true;
Of course I need to bridge the two calls together so they can speak to each other.. I am trying to bridge the call at "// ****** BRIDGE SHOULD BE HERE ****** " like this:
leg_a.sleep(1000, 0); string apiResult = fsApi.ExecuteString(string.Format("uuid_bridge {1} {0}", leg_a.GetUuid(), leg_b.GetUuid())); Debug("apiResult="+apiResult);
The console log shows "+OK {guid of leg_a}
but at the very same moment the incomming calls is beging hung up, (I can see the Debug message of my HandleHangUp() at exactly the as me time as the apiResult of the bridge. I have checked without bridge to check if codecs are the the same and they both are PCMU 8000. Please any help is appreciated! I have been trying to make this work for over a week now, but it won''t work.
note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together...
Best Regards, Mike.
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Please pastebin some debug logs, so we know where to start looking. /Peter ________________________________ Från: freeswitch-dev-bounces@lists.freeswitch.org [freeswitch-dev-bounces@lists.freeswitch.org] för Michael Lutz [mytemike72@gmail.com] Skickat: den 6 januari 2012 16:56 Till: freeswitch-dev@lists.freeswitch.org Ämne: Re: [Freeswitch-dev] bridging calls using mod_managed Hi, Anyone here who can help me with this problem? I got really stuck on this one.. Thanks for helping!, Mike Op 4 jan. 2012 om 18:58 heeft Michael Giagnocavo <mgg@giagnocavo.net<mailto:mgg@giagnocavo.net>> het volgende geschreven: Can you paste the debug log from FreeSWITCH when this happens? From: freeswitch-dev-bounces@lists.freeswitch.org<mailto:freeswitch-dev-bounces@lists.freeswitch.org> [mailto:freeswitch-dev-bounces@lists.freeswitch.org] On Behalf Of Michael Lutz Sent: Wednesday, January 04, 2012 10:10 AM To: freeswitch-dev@lists.freeswitch.org<mailto:freeswitch-dev@lists.freeswitch.org> Subject: [Freeswitch-dev] bridging calls using mod_managed Hi, I've been working with FS for some time now, and are progressing. I am working on a platform (in/ivr) which is handled by .net managed code completely. I am using just 1 application which is always launched on incomming calls. This application immedeately connects with my MSSQL server and checks validity of gateways, inbound number etc. Also a cdr is written and updated periodically while the call is active. I have als set the HandleHangUp handler to finalize the cdr and call when the calller disconnects. This whole mechanism works as a charm. This application then plays voicefiles, getdigits, and everything as I would expect. Hoewever at some point I want to dialout to an external number and connect these two calls together. I do not want to leave the originating .net app as long as my incomming caller is still online (to update the cdr and finalize the call). While these two are connected I need to update my database periodicaly (keepalive). I have been looking the internet to find what I need but i can't get it to work 100%. In fact everything works, but when I bridge the two calls together it fails. I use the following and this whole peace of code actually works, it dials out, aborts when someone hangsup and when the b_leg picks up they both get audiofile turn by turn.... It even checks outbuond status and maps this to the original call. (so really acts like a switch). Debug("Got a route=>"+route+", Let the network play the ringtone..."); leg_a.Execute("ring_ready", ""); Debug("Creating the new session..."); ManagedSession leg_b = new ManagedSession("sofia/external/"+route); // route holds {destinationNumber}@{myExternalGateway<mailto:%7bdestinationNumber%7d@%7bmyExternalGateway>} if (leg_b.Ready()) { Debug("Session_B ready!"); string fsuuid_b = leg_b.GetVariable("uuid"); Debug("Waiting for B-Leg to answer and A-Leg not to hangup..."); while (!leg_b.answered() && leg_a.Ready() ) { /* Ringing... */ } if (leg_b.answered()) { Debug("...B-Leg is answered"); AnswerCall(leg_a); while (!leg_a.answered()) { } Debug("...A-Leg is answered"); // ****** BRIDGE SHOULD BE HERE ****** Debug("As long as both legs are Ready(), we wait......"); while (leg_b.Ready() && leg_a.Ready()) { Play(leg_b, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED Play(leg_a, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED } Debug("There is one leg no longer ready..."); if (leg_a.Ready()) { Debug("Session A still ready..."); } else { Debug("Session A NO LONGER ready...");} if (leg_b.Ready()) { Debug("Session B still ready..."); } else { Debug("Session B NO LONGER ready...");} } else { Debug("A-Leg aborted while dialing..."); } if (leg_b.Ready()) { Debug("B-Leg still here, so hanging up B-Leg..."); leg_b.Hangup("NORMAL_CALL_CLEARING"); leg_b.destroy(); } } else { string obCause = leg_b.hangupCause(); leg_a.HangUp(obCause); Debug("Route failed with: "+obCause); } return true; Of course I need to bridge the two calls together so they can speak to each other.. I am trying to bridge the call at "// ****** BRIDGE SHOULD BE HERE ****** " like this: leg_a.sleep(1000, 0); string apiResult = fsApi.ExecuteString(string.Format("uuid_bridge {1} {0}", leg_a.GetUuid(), leg_b.GetUuid())); Debug("apiResult="+apiResult); The console log shows "+OK {guid of leg_a} but at the very same moment the incomming calls is beging hung up, (I can see the Debug message of my HandleHangUp() at exactly the as me time as the apiResult of the bridge. I have checked without bridge to check if codecs are the the same and they both are PCMU 8000. Please any help is appreciated! I have been trying to make this work for over a week now, but it won''t work. note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together... Best Regards, Mike. _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org<mailto:FreeSWITCH-dev@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org !DSPAM:4f07185e32767836217473!
I allready did paste logs last week on request... What logs do you want? Regards, Mike Op 6 jan. 2012 om 17:45 heeft Peter Olsson <peter.olsson@visionutveckling.se> het volgende geschreven:
Please pastebin some debug logs, so we know where to start looking.
/Peter ________________________________ Från: freeswitch-dev-bounces@lists.freeswitch.org [freeswitch-dev-bounces@lists.freeswitch.org] för Michael Lutz [mytemike72@gmail.com] Skickat: den 6 januari 2012 16:56 Till: freeswitch-dev@lists.freeswitch.org Ämne: Re: [Freeswitch-dev] bridging calls using mod_managed
Hi,
Anyone here who can help me with this problem? I got really stuck on this one..
Thanks for helping!, Mike
Op 4 jan. 2012 om 18:58 heeft Michael Giagnocavo <mgg@giagnocavo.net<mailto:mgg@giagnocavo.net>> het volgende geschreven:
Can you paste the debug log from FreeSWITCH when this happens?
From: freeswitch-dev-bounces@lists.freeswitch.org<mailto:freeswitch-dev-bounces@lists.freeswitch.org> [mailto:freeswitch-dev-bounces@lists.freeswitch.org] On Behalf Of Michael Lutz Sent: Wednesday, January 04, 2012 10:10 AM To: freeswitch-dev@lists.freeswitch.org<mailto:freeswitch-dev@lists.freeswitch.org> Subject: [Freeswitch-dev] bridging calls using mod_managed
Hi, I've been working with FS for some time now, and are progressing. I am working on a platform (in/ivr) which is handled by .net managed code completely. I am using just 1 application which is always launched on incomming calls. This application immedeately connects with my MSSQL server and checks validity of gateways, inbound number etc. Also a cdr is written and updated periodically while the call is active. I have als set the HandleHangUp handler to finalize the cdr and call when the calller disconnects. This whole mechanism works as a charm. This application then plays voicefiles, getdigits, and everything as I would expect. Hoewever at some point I want to dialout to an external number and connect these two calls together. I do not want to leave the originating .net app as long as my incomming caller is still online (to update the cdr and finalize the call). While these two are connected I need to update my database periodicaly (keepalive). I have been looking the internet to find what I need but i can't get it to work 100%. In fact everything works, but when I bridge the two calls together it fails.
I use the following and this whole peace of code actually works, it dials out, aborts when someone hangsup and when the b_leg picks up they both get audiofile turn by turn.... It even checks outbuond status and maps this to the original call. (so really acts like a switch).
Debug("Got a route=>"+route+", Let the network play the ringtone..."); leg_a.Execute("ring_ready", "");
Debug("Creating the new session..."); ManagedSession leg_b = new ManagedSession("sofia/external/"+route); // route holds {destinationNumber}@{myExternalGateway<mailto:%7bdestinationNumber%7d@%7bmyExternalGateway>} if (leg_b.Ready()) { Debug("Session_B ready!"); string fsuuid_b = leg_b.GetVariable("uuid");
Debug("Waiting for B-Leg to answer and A-Leg not to hangup..."); while (!leg_b.answered() && leg_a.Ready() ) { /* Ringing... */ }
if (leg_b.answered()) { Debug("...B-Leg is answered"); AnswerCall(leg_a); while (!leg_a.answered()) { } Debug("...A-Leg is answered");
// ****** BRIDGE SHOULD BE HERE ******
Debug("As long as both legs are Ready(), we wait......"); while (leg_b.Ready() && leg_a.Ready()) { Play(leg_b, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED Play(leg_a, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED }
Debug("There is one leg no longer ready..."); if (leg_a.Ready()) { Debug("Session A still ready..."); } else { Debug("Session A NO LONGER ready...");} if (leg_b.Ready()) { Debug("Session B still ready..."); } else { Debug("Session B NO LONGER ready...");} } else { Debug("A-Leg aborted while dialing..."); }
if (leg_b.Ready()) { Debug("B-Leg still here, so hanging up B-Leg..."); leg_b.Hangup("NORMAL_CALL_CLEARING"); leg_b.destroy(); } } else { string obCause = leg_b.hangupCause();
leg_a.HangUp(obCause); Debug("Route failed with: "+obCause); } return true;
Of course I need to bridge the two calls together so they can speak to each other.. I am trying to bridge the call at "// ****** BRIDGE SHOULD BE HERE ****** " like this:
leg_a.sleep(1000, 0); string apiResult = fsApi.ExecuteString(string.Format("uuid_bridge {1} {0}", leg_a.GetUuid(), leg_b.GetUuid())); Debug("apiResult="+apiResult);
The console log shows "+OK {guid of leg_a}
but at the very same moment the incomming calls is beging hung up, (I can see the Debug message of my HandleHangUp() at exactly the as me time as the apiResult of the bridge. I have checked without bridge to check if codecs are the the same and they both are PCMU 8000. Please any help is appreciated! I have been trying to make this work for over a week now, but it won''t work.
note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together...
Best Regards,
Mike.
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org<mailto:FreeSWITCH-dev@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org !DSPAM:4f07185e32767836217473!
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
Hi, I did managed to get something to work. I placed complete code on pastebin: http://pastebin.com/eCsYSdfk I don't know why exactly it works now, I think it has something to do with a public decalration of my leg_a as managed session and using that, now I pass the contect.Session every time and create that as a local leg_a reference and that seems to work... Still I have some problems with I need realy need somebody to help me with... 1. immediately after the bridge (log says exact same timestamp) the HangUp handler is invoked. (it seems as a separate part, as the rest of my code is handled too) Why is the hangup handler called when the bridge is started and how to avoid this? 2. After the bridge I need to get into a loop to continue my code while in the bridge, and after the bridge, depending on who hung up. So after bridge I go into while loop like: while(leg_a.bridged() && leg_b.bridged()) { } But the both return false immediately. Al other functions ( contect.Session.Ready() ) return false too, though my code continues and just continues my function. How can I make this work? My (custom debug)log shows: 2012-01-09 10:29:42.111746 [INFO] sofia.c:819 sofia/internal/****@*.*.*.*Update Callee ID to "HW-MIKE-TC01" <3120*******> 2012-01-09 10:29:42.993834 [INFO] switch_channel.c:2708 sofia/external/***********@*.*.*.* Flipping CID from "" <313*********> to "Outbound Call" <316*********> 2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============> HandleHangUp(); 2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============> Finalizing call in CDR table 2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============> apiResult=+OK 792d63a7-fa2e-43fb-b43b-32c11e2b7452 2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============> As long as both legs are Ready(), we wait...... 2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============> There is one leg no longer ready... 2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============> Session A NO LONGER ready... 2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============> Session B NO LONGER ready... 2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============> SimpleCall() ended with: SUCCESS 2012-01-09 10:29:42.993834 [ERR] switch_cpp.cpp:1227 =============> End of run... Then when I realy hangup: 2012-01-09 10:31:13.386873 [NOTICE] sofia.c:623 Hangup sofia/external/316********@*.*.*.* [CS_SOFT_EXECUTE] [NORMAL_CLEARING] 2012-01-09 10:31:13.406875 [NOTICE] switch_ivr_bridge.c:669 Hangup sofia/internal/3120********@*.*.*.* [CS_EXCHANGE_MEDIA] [NORMAL_CLEARING] 2012-01-09 10:31:13.406875 [NOTICE] switch_core_session.c:1398 Session 133 ( sofia/internal/3120*******@*.*.*.*) Ended 2012-01-09 10:31:13.406875 [NOTICE] switch_core_session.c:1400 Close Channel sofia/internal/3120*******@*.*.*.* [CS_DESTROY] Thanks in advance! Regards, Mike. 2012/1/6 Michael Lutz <mytemike72@gmail.com>
I allready did paste logs last week on request... What logs do you want?
Regards, Mike
Op 6 jan. 2012 om 17:45 heeft Peter Olsson < peter.olsson@visionutveckling.se> het volgende geschreven:
Please pastebin some debug logs, so we know where to start looking.
/Peter ________________________________ Från: freeswitch-dev-bounces@lists.freeswitch.org [ freeswitch-dev-bounces@lists.freeswitch.org] för Michael Lutz [ mytemike72@gmail.com] Skickat: den 6 januari 2012 16:56 Till: freeswitch-dev@lists.freeswitch.org Ämne: Re: [Freeswitch-dev] bridging calls using mod_managed
Hi,
Anyone here who can help me with this problem? I got really stuck on this one..
Thanks for helping!, Mike
Op 4 jan. 2012 om 18:58 heeft Michael Giagnocavo <mgg@giagnocavo.net <mailto:mgg@giagnocavo.net>> het volgende geschreven:
Can you paste the debug log from FreeSWITCH when this happens?
From: freeswitch-dev-bounces@lists.freeswitch.org<mailto: freeswitch-dev-bounces@lists.freeswitch.org> [mailto: freeswitch-dev-bounces@lists.freeswitch.org] On Behalf Of Michael Lutz Sent: Wednesday, January 04, 2012 10:10 AM To: freeswitch-dev@lists.freeswitch.org<mailto: freeswitch-dev@lists.freeswitch.org> Subject: [Freeswitch-dev] bridging calls using mod_managed
Hi, I've been working with FS for some time now, and are progressing. I am working on a platform (in/ivr) which is handled by .net managed code completely. I am using just 1 application which is always launched on incomming calls. This application immedeately connects with my MSSQL server and checks validity of gateways, inbound number etc. Also a cdr is written and updated periodically while the call is active. I have als set the HandleHangUp handler to finalize the cdr and call when the calller disconnects. This whole mechanism works as a charm. This application then plays voicefiles, getdigits, and everything as I would expect. Hoewever at some point I want to dialout to an external number and connect these two calls together. I do not want to leave the originating .net app as long as my incomming caller is still online (to update the cdr and finalize the call). While these two are connected I need to update my database periodicaly (keepalive). I have been looking the internet to find what I need but i can't get it to work 100%. In fact everything works, but when I bridge the two calls together it fails.
I use the following and this whole peace of code actually works, it dials out, aborts when someone hangsup and when the b_leg picks up they both get audiofile turn by turn.... It even checks outbuond status and maps this to the original call. (so really acts like a switch).
Debug("Got a route=>"+route+", Let the network play the ringtone..."); leg_a.Execute("ring_ready", "");
Debug("Creating the new session..."); ManagedSession leg_b = new ManagedSession("sofia/external/"+route); // route holds {destinationNumber}@{myExternalGateway<mailto:%7bdestinationNumber%7d@ %7bmyExternalGateway>} if (leg_b.Ready()) { Debug("Session_B ready!"); string fsuuid_b = leg_b.GetVariable("uuid");
Debug("Waiting for B-Leg to answer and A-Leg not to hangup..."); while (!leg_b.answered() && leg_a.Ready() ) { /* Ringing... */ }
if (leg_b.answered()) { Debug("...B-Leg is answered"); AnswerCall(leg_a); while (!leg_a.answered()) { } Debug("...A-Leg is answered");
// ****** BRIDGE SHOULD BE HERE ******
Debug("As long as both legs are Ready(), we wait......"); while (leg_b.Ready() && leg_a.Ready()) { Play(leg_b, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED Play(leg_a, "Test\\dir-no_matching_results.wav"); // REMOVE WHEN BRIDGED }
Debug("There is one leg no longer ready..."); if (leg_a.Ready()) { Debug("Session A still ready..."); } else { Debug("Session A NO LONGER ready...");} if (leg_b.Ready()) { Debug("Session B still ready..."); } else { Debug("Session B NO LONGER ready...");} } else { Debug("A-Leg aborted while dialing..."); }
if (leg_b.Ready()) { Debug("B-Leg still here, so hanging up B-Leg..."); leg_b.Hangup("NORMAL_CALL_CLEARING"); leg_b.destroy(); } } else { string obCause = leg_b.hangupCause();
leg_a.HangUp(obCause); Debug("Route failed with: "+obCause); } return true;
Of course I need to bridge the two calls together so they can speak to each other.. I am trying to bridge the call at "// ****** BRIDGE SHOULD BE HERE ****** " like this:
leg_a.sleep(1000, 0); string apiResult = fsApi.ExecuteString(string.Format("uuid_bridge {1} {0}", leg_a.GetUuid(), leg_b.GetUuid())); Debug("apiResult="+apiResult);
The console log shows "+OK {guid of leg_a}
but at the very same moment the incomming calls is beging hung up, (I can see the Debug message of my HandleHangUp() at exactly the as me time as the apiResult of the bridge. I have checked without bridge to check if codecs are the the same and they both are PCMU 8000. Please any help is appreciated! I have been trying to make this work for over a week now, but it won''t work.
note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together...
Best Regards,
Mike.
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org<mailto: FreeSWITCH-dev@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org !DSPAM:4f07185e32767836217473!
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
participants (3)
-
Michael Giagnocavo
-
Michael Lutz
-
Peter Olsson