[Freeswitch-users] Managed ESL: AccessViolationException

Grant Bagdasarian GB at cm.nl
Fri May 16 15:24:23 MSD 2014


Hello,

I'm trying to run the following code, but after a few seconds I get AccessViolationException:

class Program {
        static void Main(string[] args) {

            ESLconnection connection = new ESLconnection("192.168.1.1", 8021, "ClueCon");
            connection.SendRecv("event plain ALL");
            Task task1 = Task.Run(() => Receive(1, connection));
            Task task2 = Task.Run(() => Receive(2, connection));
            Console.ReadLine();
        }

        static void Receive(int id, ESLconnection connection) {
            while (connection.Connected() == 1) {
                ESLevent eslEvent = connection.RecvEvent();
                Console.WriteLine("{0} - {1}", id, eslEvent.Serialize("").Split(new char[] { '\r', '\n' })[0]);
            }
        }
    }

What the basic idea behind this is, is to have a Task continuously listening for a CHANNEL_HANGUP event, and have the other Task process the call in parallel.
Does the exception occur because multiple parallel tasks are trying to access the connection object?

Is the only solution to create a second ESLconnection (HANGUP Handler) and register it to receive only calls for a given UUID?

Regards,

Grant
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140516/c9738f56/attachment.html 


Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users mailing list