<div>Hi Michael,</div><div> </div><div>Here it is:</div><div> </div><div>2012-01-04 19:25:09.900945 [ERR] switch_cpp.cpp:1227 =============&gt; ...A-Leg is answered<br>2012-01-04 19:25:09.925947 [DEBUG] switch_core_session.c:875 Send signal <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} [BREAK]<br>
2012-01-04 19:25:09.925947 [DEBUG] switch_core_session.c:875 Send signal <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} [BREAK]<br>
2012-01-04 19:25:09.925947 [DEBUG] switch_core_session.c:875 Send signal <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} [BREAK]<br>
2012-01-04 19:25:09.925947 [DEBUG] switch_core_session.c:875 Send signal <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} [BREAK]<br>
2012-01-04 19:25:09.925947 [DEBUG] sofia.c:5494 Channel <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} entering state [completed][200]<br>
2012-01-04 19:25:09.925947 [DEBUG] sofia.c:5494 Channel <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} entering state [ready][200]<br>
2012-01-04 19:25:09.985953 [DEBUG] switch_core_session.c:875 Send signal <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} [BREAK]<br>
2012-01-04 19:25:10.005955 [INFO] sofia.c:819 <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} Update Callee ID to &quot;HW-MIKE-TC01&quot; &lt;{MyOriginatingNumber}&gt;<br>
2012-01-04 19:25:10.005955 [DEBUG] sofia.c:7276 dispatched freeswitch event for INFO<br>2012-01-04 19:25:10.125967 [DEBUG] switch_rtp.c:3204 Correct ip/port confirmed.<br>2012-01-04 19:25:10.906045 [INFO] switch_channel.c:2708 <a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>} Flipping CID from &quot;&quot; &lt;{MyOutboundOriginatingNumber}&gt; to &quot;Outbound Call&quot; &lt;{MyDestinationNumber}&gt;<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:1613 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) State Change CS_SOFT_EXECUTE -&gt; CS_HIBERNATE<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:1180 Send signal <a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>} [BREAK]<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:1615 (<a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>}) State Change CS_EXECUTE -&gt; CS_HIBERNATE<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_cpp.cpp:1227 AppFunction is in hangupCallback.<br>2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============&gt; HandleHangUp();<br>2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============&gt; Finalizing call in CDR table<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:362 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) Running State Change CS_HIBERNATE<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:432 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) State HIBERNATE<br>
2012-01-04 19:25:10.906045 [DEBUG] mod_sofia.c:222 <a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>} SOFIA HIBERNATE<br>2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:749 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) State Change CS_HIBERNATE -&gt; CS_RESET<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:1180 Send signal <a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>} [BREAK]<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:432 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) State HIBERNATE going to sleep<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:362 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) Running State Change CS_RESET<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:413 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) State RESET<br>
2012-01-04 19:25:10.906045 [DEBUG] mod_sofia.c:166 <a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>} SOFIA RESET<br>2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:734 <a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>} CUSTOM RESET<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:741 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) State Change CS_RESET -&gt; CS_SOFT_EXECUTE<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:1180 Send signal <a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>} [BREAK]<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:413 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) State RESET going to sleep<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:362 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) Running State Change CS_SOFT_EXECUTE<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_state_machine.c:423 (<a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>}) State SOFT_EXECUTE<br>
2012-01-04 19:25:10.906045 [DEBUG] mod_sofia.c:584 SOFIA SOFT_EXECUTE<br>2012-01-04 19:25:10.906045 [DEBUG] switch_ivr_bridge.c:759 <a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>} CUSTOM SOFT_EXECUTE<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:1180 Send signal <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} [BREAK]<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:791 Send signal <a href="mailto:sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway">sofia/internal/{MyOriginatingNumber}@{MyOriginatingGateway</a>} [BREAK]<br>
2012-01-04 19:25:10.906045 [DEBUG] switch_core_session.c:791 Send signal <a href="mailto:sofia/external/{MyDestinationNumber}@{MyDestinationGateway">sofia/external/{MyDestinationNumber}@{MyDestinationGateway</a>} [BREAK]<br>
2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============&gt; apiResult=+OK 29319eca-87df-437b-8e52-92a0427f12b2</div><div>2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============&gt; As long as both legs are Ready(), we wait......<br>
2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============&gt; There is one leg no longer ready...<br>2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============&gt; Session A NO LONGER ready...<br>2012-01-04 19:25:10.906045 [ERR] switch_cpp.cpp:1227 =============&gt; Session B still ready...<br>
<br>this is done with this piece of code:</div><div>        private string simpleCall(string route, string orig, int timeout)<br>        {<br>            string obCause = &quot;ERROR&quot;;<br>            Debug(&quot;Creating the new session...&quot;);<br>
            ManagedSession leg_b = new ManagedSession(&quot;{ignore_early_media=true,origination_caller_id_number=&quot; + orig + &quot;,originate_timeout=20}sofia/external/&quot;+route);<br>            if (leg_b.Ready())<br>
            {<br>                Debug(&quot;Session_B ready!&quot;);<br>                string fsuuid_b = leg_b.GetVariable(&quot;uuid&quot;);</div><div>                Debug(&quot;Waiting for B-Leg to answer and A-Leg not to hangup...&quot;);<br>
                while (!leg_b.answered() &amp;&amp; leg_a.Ready() ) { /* Ringing... */ }</div><div>                if (leg_b.answered())<br>                {<br>                    Debug(&quot;...B-Leg is answered&quot;);<br>
                    AnswerCall(leg_a);<br>                    while (!leg_a.answered()) { }<br>                    Debug(&quot;...A-Leg is answered&quot;);</div><div>                    leg_a.sleep(1000, 0);<br>                    string apiResult = fsApi.ExecuteString(string.Format(&quot;uuid_bridge {1} {0}&quot;, leg_a.GetUuid(), leg_b.GetUuid())); <br>
                    Debug(&quot;apiResult=&quot;+apiResult);<br>                    obCause = &quot;SUCCESS&quot;;</div><div>                    Debug(&quot;As long as both legs are Ready(), we wait......&quot;);<br>                    while (leg_b.Ready() &amp;&amp; leg_a.Ready()) <br>
                    {<br>                        // Play(leg_b, &quot;Test\\dir-no_matching_results.wav&quot;);<br>                        // Play(leg_a, &quot;Test\\dir-no_matching_results.wav&quot;);<br>                    }</div>
<div>                    Debug(&quot;There is one leg no longer ready...&quot;);<br>                    if (leg_a.Ready()) { Debug(&quot;Session A still ready...&quot;); } else { Debug(&quot;Session A NO LONGER ready...&quot;);}<br>
                    if (leg_b.Ready()) { Debug(&quot;Session B still ready...&quot;); } else { Debug(&quot;Session B NO LONGER ready...&quot;);}<br>                }<br>                else<br>                {<br>                    Debug(&quot;A-Leg aborted while dialing...&quot;);<br>
                }</div><div>                if (leg_b.Ready())<br>                {<br>                    Debug(&quot;B-Leg still here, so hanging up B-Leg...&quot;);<br>                    leg_b.Hangup(&quot;NORMAL_CALL_CLEARING&quot;);<br>
                    leg_b.destroy();<br>                }<br>            }<br>            else<br>            {<br>                obCause = leg_b.hangupCause();<br>            }<br>            Debug(&quot;SimpleCall() ended with: &quot; + obCause);<br>
            return obCause;<br>        }<br></div><div>Thanks,</div><div>Mike.</div><div> </div><div> </div><div> </div><div class="gmail_quote">2012/1/4 Michael Giagnocavo <span dir="ltr">&lt;<a href="mailto:mgg@giagnocavo.net">mgg@giagnocavo.net</a>&gt;</span><br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><div lang="EN-US" vlink="purple" link="blue"><div><p class="MsoNormal">
<span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt">Can you paste the debug log from FreeSWITCH when this happens?<u></u><u></u></span></p><p class="MsoNormal"><a name="134a9e027d650f90__MailEndCompose"><span style="color:rgb(31,73,125);font-family:&quot;Calibri&quot;,&quot;sans-serif&quot;;font-size:11pt"><u></u> <u></u></span></a></p>
<p class="MsoNormal"><b><span style="font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;font-size:10pt">From:</span></b><span style="font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;font-size:10pt"> <a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org" target="_blank">freeswitch-dev-bounces@lists.freeswitch.org</a> [mailto:<a href="mailto:freeswitch-dev-bounces@lists.freeswitch.org" target="_blank">freeswitch-dev-bounces@lists.freeswitch.org</a>] <b>On Behalf Of </b>Michael Lutz<br>
<b>Sent:</b> Wednesday, January 04, 2012 10:10 AM<br><b>To:</b> <a href="mailto:freeswitch-dev@lists.freeswitch.org" target="_blank">freeswitch-dev@lists.freeswitch.org</a><br><b>Subject:</b> [Freeswitch-dev] bridging calls using mod_managed<u></u><u></u></span></p>
<div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><p>Hi, <u></u><u></u></p><div><p class="MsoNormal">I&#39;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.<br>
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.<br>I have als set the HandleHangUp handler to finalize the cdr and call when the calller disconnects.<br>
This whole mechanism works as a charm. This application then plays voicefiles, getdigits, and everything as I would expect.<br>Hoewever at some point I want to dialout to an external number and connect these two calls together.<br>
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).<br>
I have been looking the internet to find what I need but i can&#39;t get it to work 100%. In fact everything works, but when I bridge the two calls together it fails.<u></u><u></u></p></div><div><p class="MsoNormal"><br>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).<u></u><u></u></p>
</div><p>                    Debug(&quot;Got a route=&gt;&quot;+route+&quot;, Let the network play the ringtone...&quot;);<br>                    leg_a.Execute(&quot;ring_ready&quot;, &quot;&quot;);<u></u><u></u></p><p>                    Debug(&quot;Creating the new session...&quot;);<br>
                    ManagedSession leg_b = new ManagedSession(&quot;sofia/external/&quot;+route);  // route holds <a href="mailto:%7bdestinationNumber%7d@%7bmyExternalGateway" target="_blank">{destinationNumber}@{myExternalGateway</a>}<br>
                    if (leg_b.Ready())<br>                    {<br>                        Debug(&quot;Session_B ready!&quot;);<br>                        string fsuuid_b = leg_b.GetVariable(&quot;uuid&quot;);<u></u><u></u></p>
<p>                        Debug(&quot;Waiting for B-Leg to answer and A-Leg not to hangup...&quot;);<br>                        while (!leg_b.answered() &amp;&amp; leg_a.Ready() ) { /* Ringing... */ }<u></u><u></u></p><p>
                        if (leg_b.answered())<br>                        {<br>                            Debug(&quot;...B-Leg is answered&quot;);<br>                            AnswerCall(leg_a);<br>                            while (!leg_a.answered()) { }<br>
                            Debug(&quot;...A-Leg is answered&quot;);<u></u><u></u></p><p>                            // ****** BRIDGE SHOULD BE HERE ****** <u></u><u></u></p><p>                            Debug(&quot;As long as both legs are Ready(), we wait......&quot;);<br>
                            while (leg_b.Ready() &amp;&amp; leg_a.Ready()) <br>                            {<br>                                Play(leg_b, &quot;Test\\dir-no_matching_results.wav&quot;); // REMOVE WHEN BRIDGED<br>
                                Play(leg_a, &quot;Test\\dir-no_matching_results.wav&quot;); // REMOVE WHEN BRIDGED<br>                            }<u></u><u></u></p><p>                            Debug(&quot;There is one leg no longer ready...&quot;);<br>
                            if (leg_a.Ready()) { Debug(&quot;Session A still ready...&quot;); } else { Debug(&quot;Session A NO LONGER ready...&quot;);}<br>                            if (leg_b.Ready()) { Debug(&quot;Session B still ready...&quot;); } else { Debug(&quot;Session B NO LONGER ready...&quot;);}<br>
                        }<br>                        else<br>                        {<br>                            Debug(&quot;A-Leg aborted while dialing...&quot;);<br>                        }<u></u><u></u></p><p>                        if (leg_b.Ready())<br>
                        {<br>                            Debug(&quot;B-Leg still here, so hanging up B-Leg...&quot;);<br>                            leg_b.Hangup(&quot;NORMAL_CALL_CLEARING&quot;);<br>                            leg_b.destroy();<br>
                        }<br>                    }<br>                    else<br>                    {<br>                        string obCause = leg_b.hangupCause();<u></u><u></u></p><p>                        leg_a.HangUp(obCause);<br>
                        Debug(&quot;Route failed with: &quot;+obCause);<br>                    }                <br>                    return true;<u></u><u></u></p><p>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 &quot;// ****** BRIDGE SHOULD BE HERE ****** &quot; like this:<u></u><u></u></p>
<p>leg_a.sleep(1000, 0);<br>string apiResult = fsApi.ExecuteString(string.Format(&quot;uuid_bridge {1} {0}&quot;, leg_a.GetUuid(), leg_b.GetUuid())); <br>Debug(&quot;apiResult=&quot;+apiResult);<u></u><u></u></p><p>The console log shows &quot;+OK {guid of leg_a} <u></u><u></u></p>
<p>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.<br>I have checked without bridge to check if codecs are the the same and they both are PCMU 8000.<br>
Please any help is appreciated! I have been trying to make this work for over a week now, but it won&#39;&#39;t work.<u></u><u></u></p><p>note. I have also tried originate with the api, but gives me the same problem when I try to bridge these two legs together...<u></u><u></u></p>
<div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Best Regards,<u></u><u></u></p></div><p>Mike.<u></u><u></u></p></div></div></div></div><br>_________________________________________________________________________<br>

Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-dev mailing list<br>
<a href="mailto:FreeSWITCH-dev@lists.freeswitch.org">FreeSWITCH-dev@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-dev" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-dev</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>