hhblaze / Raft.Net

Implementation of RAFT distributed consensus algorithm among TCP Peers on .NET / .NETStandard / .NETCore / dotnet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No graceful way to stop a TcpRaftNode

DevSidious opened this issue · comments

Currently one has to call Dispose() on a TcpRaftNode to make it shut down (ungracefully) resulting in:

21.08.2018 15:39:57> [ERROR] [System.ObjectDisposedException: Cannot access a disposed object. Object name: 'System.Net.Sockets.Socket'. at System.Net.Sockets.Socket.EndAccept(Byte[]& buffer, Int32& bytesTransferred, IAsyncResult asyncResult) at System.Net.Sockets.TcpListener.EndAcceptTcpClient(IAsyncResult asyncResult) at System.Net.Sockets.TcpListener.<>c.<AcceptTcpClientAsync>b__28_1(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) --- End of stack trace from previous location where exception was thrown --- at Raft.Transport.TcpRaftNode.StartTcpListener()] [] []

commented

Will take a look

commented

Ok, this you can call a graceful termination. Because await AcceptTcpClientAsync will be always terminated with exception (that is catched and logged), when you dispose the socket.