danbarua / NEventSocket

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

socket disconnect #59

Open yushu3166 opened 8 years ago

yushu3166 commented 8 years ago

hi: when I use this command"sofia status profile internal reg", socket will be disconnect.

var socket = await InboundSocket.Connect(freeswitchAddr, freeswitchESPort, freeswitchESPassword); socket .Disposed += socket _Disposed; socket .SendApi("sofia status profile internal reg") //when run finish this ,socket _Disposed will be trigger. sorry,my english is not good。…^~^

danbarua commented 8 years ago

It's hard to say what is going on without being able to see all of your code, but it's possible the socket is going out of scope and being garbage collected. I am assuming that you are testing inside a console application:

var socket = await InboundSocket.Connect(freeswitchAddr, freeswitchESPort, freeswitchESPassword);
socket.Disposed += socket _Disposed;
var apiResult = await socket .SendApi("sofia status profile internal reg");
Console.WriteLine(apiResult.ToString());
Console.ReadLine(); //block execution