C# – “Thread was being aborted” in WCF Service Call

ajaxasp.netcprtgwcf

In my program there is a aspx page that contains wcf client, that so on calls wcf service located on same server.

I`v get this exception when my wcf client calls wcf service hosted in IIS on production server.

Ex. msg: Thread was being aborted.

Ex stack:

at System.Net.UnsafeNclNativeMethods.OSSOCK.recv(IntPtr socketHandle,
Byte* pinnedBuffer, Int32 len, SocketFlags socketFlags) at
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags, SocketError& errorCode) at
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32 size) at System.Net.PooledStream.Read(Byte[] buffer, Int32
offset, Int32 size) at System.Net.Connection.SyncRead(HttpWebRequest
request, Boolean userRetrievedStream, Boolean probeRead) at
System.Net.ConnectStream.ProcessWriteCallDone(ConnectionReturnResult
returnResult) at
System.Net.ConnectStream.CallDone(ConnectionReturnResult returnResult)
at System.Net.ConnectStream.ResubmitWrite(ConnectStream oldStream,
Boolean suppressWrite) at
System.Net.HttpWebRequest.EndWriteHeaders_Part2() at
System.Net.HttpWebRequest.EndWriteHeaders(Boolean async) at
System.Net.HttpWebRequest.WriteHeadersCallback(WebExceptionStatus
errorStatus, ConnectStream stream, Boolean async) at
System.Net.ConnectStream.WriteHeaders(Boolean async) at
System.Net.HttpWebRequest.EndSubmitRequest() at
System.Net.HttpWebRequest.GetResponse() at
System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan
timeout) at
System.ServiceModel.Channels.RequestChannel.Request(Message message,
TimeSpan timeout) at
System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message
message, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation) at
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at
StationService.IStationService.GetCurrentStationTrack(String
stationId) at
StationService.StationServiceClient.GetCurrentStationTrack(String
stationId) at GetSongJS.getMarq(String radioIdentifier)

I using PRTG Ipmonitor and it give me too many requests on "Requests Current" sensor.
My site becomes anavailable in browser.
If a delete this page that calls service all is going to be OK.

Best Answer

It sounds like you are not closing the WCF client.

What I think is happening is:

  • User calls the aspx page
  • aspx page calls the service
  • aspx page returns to the user
  • the service client is not closed, therefore request is open and number of current requests is high
  • eventually you have the max number of requests open
  • the page waits for a free connection, when it does not get one the aspx page timesout
  • you then get a thread abort exception from the timeout
Related Topic