[Freeswitch-dev] Issue while creating a session for an incoming call in managed application

Peter Olsson peter.olsson at visionutveckling.se
Wed Jun 13 20:58:09 MSD 2012

Seems strange to create a new endpoint interface on each new incoming call. That interface is something you usually create using switch_loadable_module_create_module_interface(), and that is something you do when the module is loaded (that interface is valid until the modules is unloaded again).

I've never used the managed stuff myself, so I say as Michael, first try using C to get basic stuff working, and then try to port that to managed code.

Från: freeswitch-dev-bounces at lists.freeswitch.org [freeswitch-dev-bounces at lists.freeswitch.org] för Michael Giagnocavo [mgg at giagnocavo.net]
Skickat: den 13 juni 2012 17:33
Till: freeswitch-dev at lists.freeswitch.org
Ämne: Re: [Freeswitch-dev] Issue while creating a session for an incoming call in managed application

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.

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.


From: freeswitch-dev-bounces at lists.freeswitch.org [mailto:freeswitch-dev-bounces at lists.freeswitch.org] On Behalf Of Papineni, Suneel
Sent: Wednesday, June 13, 2012 9:29 AM
To: freeswitch-dev at lists.freeswitch.org
Subject: [Freeswitch-dev] Issue while creating a session for an incoming call in managed application


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.

To implement this, I have written a managed module in which “ILoadNotificationPlugin” is implemented where config (client’s interface config) is loaded.

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 “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
Here is the code that I am using… Could someone guide me if I am doing this correctly.

Note: I am following “mod_skypopen” as an example…

public static int new_inbound_channel(private_object pobject)
                                SWIGTYPE_p_switch_core_session session = null;
                                SWIGTYPE_p_switch_channel channel = null;
                                switch_endpoint_interface intf = new switch_endpoint_interface();
                                intf.interface_name = "NET_interface";
                                intf.io_routines = io_routines;
                                intf.state_handler = state_handlers;
                                Api fsApi = new Api();
                                String uuid = fsApi.ExecuteString("create_uuid");
                                                session = freeswitch.switch_core_session_request_uuid(intf, switch_call_direction_t.SWITCH_CALL_DIRECTION_INBOUND, 0, null, uuid);  //I am getting the above issue here….
                                                if (session != null)
                                                                freeswitch.switch_core_session_add_stream(session, null);
                                                                channel = freeswitch.switch_core_session_get_channel(session);
                                                                if (channel == null)
                                                                                return 0;
                                                                freeswitch.switch_channel_set_variable_name_printf(channel, "waste", "false");

                                                                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");
                                                                if (pobject.caller_profile != null)
                                                                                freeswitch.switch_channel_set_name(channel, "name");
                                                                                freeswitch.switch_channel_set_caller_profile(channel, pobject.caller_profile);
                                                                freeswitch.switch_channel_set_state_flag(channel, switch_channel_flag_t.CF_GEN_RINGBACK);
                                                                switch_status_t session_status = freeswitch.switch_core_session_thread_launch(session);
                                                                if (session_status != switch_status_t.SWITCH_STATUS_SUCCESS)
                                                                                return 0;
                                catch (Exception exp)
                                                string expstring = exp.Message;
                                return 0;

Thanks & Regards

Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-dev mailing list