The problem I am experiencing is that if I leave my WCF service host
running idly for a period (beyond the binding receive timeout?) then I
find that subsequent method invocations from the client can result in
a stream of "CommunicationException" ,
"CommunicationObjectAbortedException", "IOException" and
"SocketException" messages occuring inside .NET. If I retry the
activity then (most of the time) it will subsequently succeed.
It is as if the proxy instance that the Windsor WCF client returns is
becoming invalid, but rather than silently destroying it and creating
a new one it lets the error flow through and instead creates a new one
one on the next request. Does that make any sense?
Is anyone out there actually using this facility in a production non-
web application? The documentation is non-existent, the few examples I
have seen are either web app based, out of date or too simple to be
useful (as are the unit tests). I'm banging my head against the wall
with this - it could be something really dumb I am doing in my usage
but without relevant examples it is impossible to know. I'm very close
to giving up on WCF and going back to "trusty" .NET remoting.
I have posted a small repro project showing how I register the service
hosts and client which you can download from here:
http://www.kiwidude.com/WcfDemo.zip
Here is an example exception stack trace of the exception...
System.ServiceModel.CommunicationException: The socket connection was
aborted. This could be caused by an error processing your message or a
receive timeout being exceeded by the remote host, or an underlying
network resource issue. Local socket timeout was '00:10:00'. --->
System.IO.IOException: The write operation failed, see inner
exception. ---> System.ServiceModel.CommunicationException: The socket
connection was aborted. This could be caused by an error processing
your message or a receive timeout being exceeded by the remote host,
or an underlying network resource issue. Local socket timeout was
'00:10:00'. ---> System.Net.Sockets.SocketException: An existing
connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset,
Int32 size, SocketFlags socketFlags)
at System.ServiceModel.Channels.SocketConnection.Write(Byte[]
buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.SocketConnection.Write(Byte[]
buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte[]
buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager
bufferManager)
at System.ServiceModel.Channels.BufferedConnection.Write(Byte[]
buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionStream.Write(Byte[]
buffer, Int32 offset, Int32 count)
at System.Net.Security.NegotiateStream.StartWriting(Byte[] buffer,
Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.ProcessWrite(Byte[] buffer,
Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
--- End of inner exception stack trace ---
at System.Net.Security.NegotiateStream.ProcessWrite(Byte[] buffer,
Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.Write(Byte[] buffer, Int32
offset, Int32 count)
at System.ServiceModel.Channels.StreamConnection.Write(Byte[]
buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.StreamConnection.Write(Byte[]
buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
at System.ServiceModel.Channels.StreamConnection.Write(Byte[]
buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout,
BufferManager bufferManager)
at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSend
(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.OutputChannel.Send(Message message,
TimeSpan timeout)
at System.ServiceModel.Dispatcher.DuplexChannelBinder.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.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object
[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService
(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage
(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke
(MessageData& msgData, Int32 type)
at WcfDemo.Common.Interfaces.IFooService.GetFooStuff()
at
IFooServiceProxy2a1d2ae2b1bc4e319a4a501297fcaa83.InvocationGetFooStuff_79.InvokeMethodOnTarget
()
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at
Castle.Facilities.WcfIntegration.WcfManagedChannelInterceptor.Intercept
(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at IFooServiceProxy2a1d2ae2b1bc4e319a4a501297fcaa83.GetFooStuff()
at WcfDemo.WinClient.MainForm.OnCallFooButtonClick(Object sender,
EventArgs e) in C:\Dev\Misc\WcfDemo\WcfDemo.WinClient\MainForm.cs:line
23