Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TcpEx: invalid TCP packet crashing a running server #40

Closed
yallie opened this issue Feb 13, 2018 · 0 comments
Closed

TcpEx: invalid TCP packet crashing a running server #40

yallie opened this issue Feb 13, 2018 · 0 comments
Milestone

Comments

@yallie
Copy link
Member

yallie commented Feb 13, 2018

Got an strange issue on one of my client's servers.
The unhandled exception occurs on a thread pool I/O thread:

2018.02.13 15:14:00 Topshelf.Hosts.ConsoleRunHost: The service threw an unhandled exception
System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.EndAccept(Byte[]& buffer, Int32& bytesTransferred, IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.EndAccept(IAsyncResult asyncResult)
   at Zyan.Communication.Protocols.Tcp.DuplexChannel.Manager.listener_Accept(IAsyncResult ar) in D:\Externals\Zyan\source\Zyan.Communication\Protocols\Tcp\DuplexChannel\Manager.cs:line 241
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Turns out to be an issue with some monitoring software.
The monitor seems to be pinging known addresses and immediately
closing the connection as long as it sees that the remote party is listening:

image

Seems that Zyan doesn't handle this situation properly (Manager.cs: line 241):

Socket client;
try
{
	client = listener.EndAccept(ar); // ** unhandled SocketException here**

	// Wait for next Client request
	listener.BeginAccept(new AsyncCallback(listener_Accept), new object[] { listener, channel });
}
catch (ObjectDisposedException ex)
{
	// the listener was closed
	Trace.WriteLine("TcpEx.Manager: the listener was closed. Got exception: " + ex.ToString());
	return;
}

The solution seems to be simply ignore the broken incoming connection.

@yallie yallie added this to the 2.10 milestone Feb 13, 2018
yallie added a commit to yallie/Zyan that referenced this issue Feb 13, 2018
@yallie yallie closed this as completed Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant