<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">I suggest writing the same code in C, just to troubleshoot and make sure you’re calling the switch_core_session_request_uuid function properly. That exception means “access violation” aka segfault.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">You can also turn on the debugger and step into the native code and see where it’s failing. (I’m not sure if you break on exception if it’ll show you.) Basically, you have to troubleshoot it like a normal C app.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">-Michael<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="color:#1F497D"><o:p> </o:p></span></a></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> freeswitch-dev-bounces@lists.freeswitch.org [mailto:freeswitch-dev-bounces@lists.freeswitch.org]
<b>On Behalf Of </b>Papineni, Suneel<br>
<b>Sent:</b> Wednesday, June 13, 2012 9:29 AM<br>
<b>To:</b> freeswitch-dev@lists.freeswitch.org<br>
<b>Subject:</b> [Freeswitch-dev] Issue while creating a session for an incoming call in managed application<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am having a third party VoIP client which exposes API in .NET to communicate with my application. I want to use this client as an endpoint in Freeswitch (like how it is implemented in “mod_skypopen” module), so that calls coming to this
client can be handled at Freeswitch and (if required) bridge calls to clients connected to Freeswitch.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">To implement this, I have written a managed module in which “ILoadNotificationPlugin” is implemented where config (client’s interface config) is loaded.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">When there is an incoming call (ringing state) to the client, I get handle in managed module and trying to establish a session at freeswitch. While doing this I am getting exception as “<b>Attempted to read or write protected memory. This
is often an indication that other memory is corrupt</b>.”<o:p></o:p></p>
<p class="MsoNormal">Here is the code that I am using… Could someone guide me if I am doing this correctly.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Note: I am following “mod_skypopen” as an example…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">public static int new_inbound_channel(private_object pobject)<o:p></o:p></p>
<p class="MsoNormal"> {<o:p></o:p></p>
<p class="MsoNormal"> SWIGTYPE_p_switch_core_session session = null;<o:p></o:p></p>
<p class="MsoNormal"> SWIGTYPE_p_switch_channel channel = null;<o:p></o:p></p>
<p class="MsoNormal"> switch_endpoint_interface intf = new switch_endpoint_interface();<o:p></o:p></p>
<p class="MsoNormal"> intf.interface_name = "NET_interface";<o:p></o:p></p>
<p class="MsoNormal"> intf.io_routines = io_routines;<o:p></o:p></p>
<p class="MsoNormal"> intf.state_handler = state_handlers;<o:p></o:p></p>
<p class="MsoNormal"> freeswitch.switch_core_set_globals();<o:p></o:p></p>
<p class="MsoNormal"> Api fsApi = new Api();<o:p></o:p></p>
<p class="MsoNormal"> String uuid = fsApi.ExecuteString("create_uuid");<o:p></o:p></p>
<p class="MsoNormal"> try<o:p></o:p></p>
<p class="MsoNormal"> {<o:p></o:p></p>
<p class="MsoNormal"> session = freeswitch.switch_core_session_request_uuid(intf, switch_call_direction_t.SWITCH_CALL_DIRECTION_INBOUND, 0, null, uuid); //<b>I am getting the above issue here….</b><o:p></o:p></p>
<p class="MsoNormal"> if (session != null)<o:p></o:p></p>
<p class="MsoNormal"> {<o:p></o:p></p>
<p class="MsoNormal"> freeswitch.switch_core_session_add_stream(session, null);<o:p></o:p></p>
<p class="MsoNormal"> channel = freeswitch.switch_core_session_get_channel(session);<o:p></o:p></p>
<p class="MsoNormal"> if (channel == null)<o:p></o:p></p>
<p class="MsoNormal"> {<o:p></o:p></p>
<p class="MsoNormal"> freeswitch.switch_core_session_destroy_state(session);<o:p></o:p></p>
<p class="MsoNormal"> return 0;<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"> freeswitch.switch_channel_set_variable_name_printf(channel, "waste", "false");<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> pobject.caller_profile = freeswitch.switch_caller_profile_new(freeswitch.switch_core_session_get_pool(session), "NETClient", "dialplan", "callid_name", "callid_number", null,
null, null, null, "mod_netclient", "context", "destination");<o:p></o:p></p>
<p class="MsoNormal"> if (pobject.caller_profile != null)<o:p></o:p></p>
<p class="MsoNormal"> {<o:p></o:p></p>
<p class="MsoNormal"> freeswitch.switch_channel_set_name(channel, "name");<o:p></o:p></p>
<p class="MsoNormal"> freeswitch.switch_channel_set_caller_profile(channel, pobject.caller_profile);<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"> freeswitch.switch_channel_set_state_flag(channel, switch_channel_flag_t.CF_GEN_RINGBACK);<o:p></o:p></p>
<p class="MsoNormal"> switch_status_t session_status = freeswitch.switch_core_session_thread_launch(session);<o:p></o:p></p>
<p class="MsoNormal"> if (session_status != switch_status_t.SWITCH_STATUS_SUCCESS)<o:p></o:p></p>
<p class="MsoNormal"> {<o:p></o:p></p>
<p class="MsoNormal"> freeswitch.switch_core_session_destroy_state(session);<o:p></o:p></p>
<p class="MsoNormal"> return 0;<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"> catch (Exception exp)<o:p></o:p></p>
<p class="MsoNormal"> {<o:p></o:p></p>
<p class="MsoNormal"> string expstring = exp.Message;<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"> return 0;<o:p></o:p></p>
<p class="MsoNormal"> }<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks & Regards<o:p></o:p></p>
<p class="MsoNormal">Suneel<o:p></o:p></p>
</div>
</body>
</html>