BogdanovKirill / RtspClientSharp

Pure C# RTSP client for .NET Standard without external dependencies and with true async nature. I welcome contributions.
MIT License
706 stars 284 forks source link

Something got disposed after call ConnectAsync #57

Open bpcuong2013 opened 4 years ago

bpcuong2013 commented 4 years ago

using (var rtspClient = new RtspClient(new ConnectionParameters(new Uri(RtspUrl)))) { rtspClient.FrameReceived += (sender, rawFrame) => ReceiveFrame(rawFrame); await rtspClient.ConnectAsync(token); await rtspClient.ReceiveAsync(token); }

The exception happens at calling ReceiveAsync method. Please help this one. Thanks!

System.IO.IOException: Unable to read data from the transport connection: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'.. ---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'. at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult, SocketError& errorCode) at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncTrimPromise1.Complete(TInstance thisRef, Func3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at RtspClientSharp.Tpkt.TpktStream.<FindNextPacketAsync>d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at RtspClientSharp.Tpkt.TpktStream.<ReadAsync>d__7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at RtspClientSharp.Rtsp.RtspClientInternal.<ReceiveOverTcpAsync>d__34.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at RtspClientSharp.Rtsp.RtspClientInternal.<ReceiveAsync>d__19.MoveNext() --- End of inner exception stack trace --- ---> (Inner Exception #0) System.IO.IOException: Unable to read data from the transport connection: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'.. ---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'. at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult, SocketError& errorCode) at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult) at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncTrimPromise1.Complete(TInstance thisRef, Func3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at RtspClientSharp.Tpkt.TpktStream.d9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at RtspClientSharp.Tpkt.TpktStream.d7.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at RtspClientSharp.Rtsp.RtspClientInternal.d34.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at RtspClientSharp.Rtsp.RtspClientInternal.d19.MoveNext()<---