danbarua / NEventSocket

A reactive FreeSwitch eventsocket library for Modern .Net
Mozilla Public License 2.0
74 stars 37 forks source link

using InBoundSocket auto outcall problem. #35

Closed yojinjin closed 8 years ago

yojinjin commented 8 years ago

here is the main code.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ' // using static socket. public static InboundSocket socket;

static void Main(string[] args) {

socket = await InboundSocket.Connect("127.0.0.1", 8021, "ClueCon", 0);

//subscribe events......
socket.Events.Where(x => x.EventName == EventName.ChannelAnswer).Subscribe(async y =>
            {
            });

}

//in thread auto out call while (true) { .....

InBoundAutoCall(list_ky[j], m_num.Tele, m_num.Id, op);

Thread.Sleep(50); .....

}

public static async void InBoundAutoCall(string callerno, string tele, int pool_id, OriginateOptions op) { try { op.CallerIdNumber = callerno; op.CallerIdName = callerno; op.HangupAfterBridge = true; op.TimeoutSeconds = 20; op.ReturnRingReady = true; op.ChannelVariables.Add("callerno", callerno); op.ChannelVariables.Add("calledno", tele);

    var result = await socket.Originate("sofia/gateway/" + callerno + "/" + tele, op);
    if (result.Success)
    {

    }
    else
    {

    }

}
catch (Exception ex)
{

}

}`

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

When the number of concurrent calls, at around 100, there will be a socket problem. Originate returns false. Then I look at the number of freeswitch channels, but the number of channels has been 0. After we close the program, reopen the socket connection, socket can work for a while, but once the amount reached 100 or so, it will appear the above situation.Is something error with us?

regards.

danbarua commented 8 years ago

First off, you can investigate the HangupCause property to see why the originate failed.

But I recommend you install a logging library into your project to get a better view of what's going on. NEventSocket uses LibLog which will automatically detect and route log messages to most popular logging libraries. I personally use NLog.

With Trace level logging you get a full picture of all messages flowing through NEventSocket which is useful for debugging, just be sure to adjust the logging level to Info or Warning in production for performance reasons.

If you are having issues with NEventSocket, it always helps to post Trace level log output so we can get an idea of what's going on.

yojinjin commented 8 years ago

I tried it yesterday. If we concurrent outbound call using SendCommand method directly launch command Originate, so at the time of concurrent will not appear freeswitch call volume after reaching a certain number, number of freeswitch calls gradually becomes zero. If you call the Originate method of Inbound, the above situation will appear. This may be a problem with the Originate method.

yojinjin commented 8 years ago

calls count 0 not work calls count 0 not work.txt calls count about 600 work fine calls count about 600 work fine.txt

calls count 0 not work using Originate method. calls count about 600 using SendCommand like this.

var originateString = string.Format("{0}{1} {2}", op, "sofia/gateway/88165450/15311111111", "'&park()'");

            Guid jobUUID = Guid.NewGuid();

            var backgroundApiCommand = originateString != null
                                           ? "bgapi {0} {1}\nJob-UUID: {2}".Fmt("originate", originateString, jobUUID)
                                           : "bgapi {0}\nJob-UUID: {1}".Fmt("originate", jobUUID);

            await socket.SendCommand(backgroundApiCommand);
danbarua commented 8 years ago

Please see related issue https://github.com/danbarua/NEventSocket/issues/29 and sample code: https://github.com/danbarua/NEventSocket/blob/master/src/NEventSocket.Examples/Examples/VoiceBlaster.cs

danbarua commented 8 years ago

Can you show me the logs for 'calls count 0 not work using Originate method.'?

yojinjin commented 8 years ago

https://github.com/danbarua/NEventSocket/files/267343/calls.count.0.not.work.txt

I have uploaded.

yojinjin commented 8 years ago

I use SendCommand method to send Concurrent call. now work fine.

danbarua commented 8 years ago

@yojinjin seems to be more of an application issue than a library issue - closing for now but re-open if you are still having problems.