I have already seen following questions and their non-working answers.
- No matter what I try: The I/O operation has been aborted because of either a thread exit or an application request
- The I/O operation has been aborted because of either a thread exit or an application request
- The I/O operation has been aborted because of either a thread exit or an application request
I have a console application with which I am stress testing my WCF service. When I make more than 80 simultaneous calls to the service, sometimes it works all fine and sometimes some of the calls fail with following exception.
Exception Type: System.Net.Sockets.SocketException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message: The I/O operation has been aborted because of either a thread exit or an application request
StackTrace:
at System.ServiceModel.Channels.SocketConnection.HandleReceiveAsyncCompleted()
at System.ServiceModel.Channels.SocketConnection.OnReceiveAsync(Object sender, SocketAsyncEventArgs eventArgs)
at System.ServiceModel.Channels.SocketConnection.OnReceiveAsyncCompleted(Object sender, SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncFailure(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
I am calling following code using loops :
var tcpb = new NetTcpBinding();
TimeSpan timeOutAfter = new TimeSpan(0, 10,0);
tcpb.OpenTimeout = timeOutAfter;
tcpb.SendTimeout = timeOutAfter;
tcpb.CloseTimeout = timeOutAfter;
tcpb.Security.Mode = SecurityMode.None;
string address = "net.tcp://" + MYIP + ":" + PORTNUMBER + "/" + PORTTYPE + "/";
ChannelFactory<ServiceName> channelFactory = new ChannelFactory<ServiceName>(tcpb,address);
var client = channelFactory.CreateChannel();
((IClientChannel)client).Open();
//Function Call here
((IClientChannel)client).Close();
channelFactory.Close();
Any ideas ans solutions are greatly appreciated.