I have a web form that is sending data to a third party service using this library from http://www.xml-rpc.net.
Recently the form has started to throw exceptions. I have tried enabling trace in the web.config to see what data is going back and forth, but this seems to fix the problem, or at least stop the exception being thrown.
Any ideas what could be happening, or how I can diagnose this without apparently fixing the problem?
The trace code:
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.Net">
<listeners>
<add name="WebPageTraceListener"
type="System.Web.WebPageTraceListener, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</listeners>
</source>
</sources>
<switches>
<add name="System.Net" value="Verbose" />
</switches>
</system.diagnostics>
The exception message:
System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
[SocketException (0x2745): An established connection was aborted by the software in your host machine]
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +73
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +131
[IOException: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine.]
System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size) +313
System.Xml.XmlTextReaderImpl.ReadData() +444
System.Xml.XmlTextReaderImpl.EatWhitespaces(BufferBuilder sb) +285
System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() +74
System.Xml.XmlTextReaderImpl.ParseDocumentContent() +187
System.Xml.XmlTextReaderImpl.Read() +151
System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +48
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +129
System.Xml.XmlDocument.Load(XmlReader reader) +108
System.Xml.XmlDocument.Load(Stream inStream) +91
CookComputing.XmlRpc.XmlRpcSerializer.DeserializeResponse(Stream stm, Type svcType) +189
[XmlRpcIllFormedXmlException: Response from server does not contain valid XML.]
CookComputing.XmlRpc.XmlRpcSerializer.DeserializeResponse(Stream stm, Type svcType) +238
CookComputing.XmlRpc.XmlRpcClientProtocol.ReadResponse(XmlRpcRequest req, WebResponse webResp, Stream respStm, Type returnType) +111
CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke(Object clientObj, MethodInfo mi, Object[] parameters) +762
CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke(MethodInfo mi, Object[] Parameters) +11
XmlRpcProxyfd5eb8e7-d547-4544-bd38-7d6dc1366a49.login(String username, String password) +120
I think that the key may be near the bottom:
+129 System.Xml.XmlDocument.Load(XmlReader reader) +108 System.Xml.XmlDocument.Load(Stream inStream) +91 CookComputing.XmlRpc.XmlRpcSerializer.DeserializeResponse(Stream stm, Type svcType) +189 [XmlRpcIllFormedXmlException: Response from server does not contain valid XML.]
Your remote server is responding with an invalid xml document, and it looks like your connection is dying because of it.
Related
I have added system.diagnostics wcf tracing to my window service that hosts couple of wcf end points.
Because this is a production service i have reduce the 'switchValue' to "Error, Critical, Warning" in order to avoid huge trace files. The problem is that now when I get an exception in the trace there is no reference as to which end point had raised the exception.
Example for such an entry in the trace file bellow.
Thanks
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>131075</EventID>
<Type>3</Type>
<SubType Name="Error">0</SubType>
<Level>2</Level>
<TimeCreated SystemTime="2020-07-04T12:21:06.1749193Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
<Execution ProcessName="Adapter" ProcessID="3440" ThreadID="107" />
<Channel />
<Computer>XX-01</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
<TraceIdentifier>http://msdn.microsoft.com/en-US/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier>
<Description>Throwing an exception.</Description>
<AppDomain>Casino3rdPartyAdapter.exe</AppDomain>
<Exception>
<ExceptionType>System.ServiceModel.ProtocolException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.</Message>
<StackTrace>
at System.ServiceModel.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
at System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
at System.ServiceModel.Channels.HttpInput.GetMessageBuffer()
at System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult.DecodeBufferedMessageAsync()
at System.ServiceModel.Channels.HttpInput.ParseMessageAsyncResult.BeginParse()
at System.ServiceModel.Channels.HttpInput.BeginParseIncomingMessage(HttpRequestMessage httpRequestMessage, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginParseIncomingMessage(AsyncCallback asynCallback, Object state)
at System.ServiceModel.Channels.HttpPipeline.EnqueueMessageAsyncResult..ctor(ReplyChannelAcceptor acceptor, Action dequeuedCallback, HttpPipeline pipeline, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpPipeline.EmptyHttpPipeline.BeginProcessInboundRequest(ReplyChannelAcceptor replyChannelAcceptor, Action dequeuedCallback, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.HttpChannelListener`1.HttpContextReceivedAsyncResult`1.ProcessHttpContextAsync()
at System.ServiceModel.Channels.HttpChannelListener`1.BeginHttpContextReceived(HttpRequestContext context, Action acceptorCallback, AsyncCallback callback, Object state)
at System.ServiceModel.Channels.SharedHttpTransportManager.EnqueueContext(IAsyncResult listenerContextResult)
at System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContextCore(IAsyncResult listenerContextResult)
at System.ServiceModel.Channels.SharedHttpTransportManager.OnGetContext(IAsyncResult result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.ListenerAsyncResult.IOCompleted(ListenerAsyncResult asyncResult, UInt32 errorCode, UInt32 numBytes)
at System.Net.ListenerAsyncResult.WaitCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>
<ExceptionString>System.ServiceModel.ProtocolException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.</ExceptionString>
<DataItems>
<Data>
<Key>System.ServiceModel.Channels.HttpInput.HttpStatusCode</Key>
<Value>RequestEntityTooLarge</Value>
</Data>
</DataItems>
</Exception>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
I am using a RestClient app to communicate with my WCF service .and I am getting the following exception
The underlying connection was closed: An unexpected error occurred on a receive.
This is the C# code I use
string q = string.Format(#"xxxxxxxxxxxxxxxxxxxxxxxxxxx");
WebClient client = new WebClient();
string Url = string.Format("{0}/Get?queries={1}", BaseUrl,HttpUtility.UrlEncodeUnicode(q));
client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
var result = client.DownloadString(Url);
Console.WriteLine("======================output================================");
Console.WriteLine(result);
Console.WriteLine("===========================================");
Here is the error message
System.Net.WebException was caught
HResult=-2146233079
Message=The underlying connection was closed: An unexpected error occurred on a receive.
Source=System
StackTrace:
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadString(Uri address)
at System.Net.WebClient.DownloadString(String address)
at RestClient.Program.GetRecordsTest() in C:\Users\Wiemon\Downloads\RestAppClient\RestAppClient\Program.cs:line 118
InnerException: System.IO.IOException
HResult=-2146232800
Message=Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Source=System
StackTrace:
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.TlsStream.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)
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=An existing connection was forcibly closed by the remote host
Source=System
ErrorCode=10054
NativeErrorCode=10054
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException:
Here is my binding
<binding name="wsHttpEndpoint" >
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="Certificate" />
<message clientCredentialType="Certificate" />
</security>
</binding>
And my endpoint behavior ,not that I set maxItemsInObjectGraph="2147483647"
<behavior name="MyEndpointBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<clientCredentials>
<clientCertificate findValue="xxxxxxxxxxxxxxxxxx" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="My" />
<serviceCertificate>
<authentication certificateValidationMode="None" revocationMode="NoCheck" />
</serviceCertificate>
</clientCredentials>
</behavior>
Its common (generic) message.
You should use Trace Viewer Tool (SvcTraceViewer.exe) to find out server error
I had similar errors coming from the depths of my http bindings in WCF.
client -> The underlying connection was closed: An unexpected error occurred on a receive.
client -> Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
server (got this with the help of "procdump") -> The I/O operation has been aborted because of either a thread exit or an application request
Eventually after many hours I came upon the HTTP.sys logging (in C:\WINDOWS\System32\LogFiles\HTTPERR ) and I discovered that the WCF self-hosted service connections were being forcibly dropped (on purpose) because of an obscure configuration issue (minimum send rate bytes per second). Unfortunately it took another few hours to reconfigure that (you cannot do it via "netsh http add timeout" so you have to do it within the app or within IIS when not self-hosted).
I dont't know if is the same error, but in my case, the exception was in Json, that cannot convert the Date value, because it was empty.
DateTime values that are greater than DateTime.MaxValue or smaller than DateTime.MinValue when converted to UTC cannot be serialized to JSON.
The trace viewer was very useful to find the issue.
Configure WCF tracing in your app.config / web.config and check Error.svclog (it will be created near your binary file) for details.
In my case it was because of using Auto-property initializer (property without setter) - a feature from C# 6.0
<Message>No set method for property 'FailedCount' in type 'MyProject.Contracts.Data.SyncStatusByVersion'.</Message>
<StackTrace> at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.ThrowInvalidDataContractException(String message, Type type)
at WriteSyncStatusByVersionToJson(XmlWriterDelegator , Object , XmlObjectSerializerWriteContextComplexJson , ClassDataContract , XmlDictionaryString[] )
...
</StackTrace>
To configure WCF tracing:
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true" >
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="myUserTraceSource" switchValue="Information, ActivityTracing">
<listeners>
<add name="xml"/>
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Error.svclog" />
</sharedListeners>
</system.diagnostics>
I'm using AppFabric caching for Windows Server 1.1. I'm trying to add an object of 80MB to the cache which is located on another server on the network. I get the following error:
ErrorCode:SubStatus:There is a temporary failure.
Please retry later. (One or more specified cache servers
are unavailable, which could be caused by busy network or servers. For
on-premises cache clusters, also verify the following conditions.
Ensure that security permission has been granted for this client
account, and check that the AppFabric Caching Service is allowed
through the firewall on all cache hosts. Also the MaxBufferSize on the
server must be greater than or equal to the serialized object size
sent from the client.): inner
System.ServiceModel.CommunicationException: The socket was aborted
because an asynchronous receive from the socket did not complete
within the allotted timeout of 00:01:00. The time allotted to this
operation may have been a portion of a longer timeout. --->
System.Net.Sockets.SocketException: An established connection was
aborted by the software in your host machine 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.SocketConnection.Write(Byte[] buffer,
Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout,
BufferManager bufferManager) 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,
BufferManager bufferManager) at
System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSend(Message
message, TimeSpan timeout) at
System.ServiceModel.Channels.OutputChannel.Send(Message message,
TimeSpan timeout) at
Microsoft.ApplicationServer.Caching.WcfClientChannel.SendOnChannel(EndpointID
endpoint, TimeSpan& timeout, WaitCallback callback, Object state,
Boolean async, IDuplexSessionChannel channel, Message message)
I can add smaller objects fine to the remote server so it's obviously something to do with the size. I've also installed the Cumulative update package 3 for AppFabric. I've disabled all security. Any ideas?
Server Config File:
<configuration>
<configSections>
<section name="dataCache" type="Microsoft.ApplicationServer.Caching.DataCacheSection, Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<dataCache size="Small">
<caches partitionCount="32">
<cache consistency="StrongConsistency" name="default" minSecondaries="0">
<policy>
<eviction type="Lru" />
<expiration defaultTTL="1440" isExpirable="true" />
</policy>
</cache>
</caches>
<hosts>
<host replicationPort="22236" arbitrationPort="22235" clusterPort="22234"
hostId="1216617116" size="6126" leadHost="true" account="test$"
cacheHostName="AppFabricCachingService" name="test.com"
cachePort="22233" />
</hosts>
<advancedProperties>
<securityProperties mode="None" protectionLevel="None">
<authorization>
<allow users="IIS AppPool\test" />
</authorization>
</securityProperties>
<transportProperties maxBufferPoolSize="26843545600" maxBufferSize="838860800" receiveTimeout="40000" />
</advancedProperties>
<deploymentSettings>
<deploymentMode value="RoutingClient" />
</deploymentSettings>
</dataCache>
</configuration>
Section from Web.config from Client which is trying to push to AppFabric:
<dataCacheClient requestTimeout="60000" channelOpenTimeout="12000" maxConnectionsToServer="1">
<localCache isEnabled="false" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
<clientNotification pollInterval="300" maxQueueLength="10000"/>
<securityProperties mode="None" protectionLevel="None" />
<transportProperties connectionBufferSize="131072" maxBufferPoolSize="568435456" maxBufferSize="183886080" maxOutputDelay="2" channelInitializationTimeout="60000" receiveTimeout="60000" /> </dataCacheClient>
The connection is established in code as follows:
DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];
servers[0] = new DataCacheServerEndpoint("remoteServerName", 22233);
DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration();
factoryConfig.Servers = servers;
//Pass configuration settings to cacheFactory constructor
_factory = new DataCacheFactory(factoryConfig);
_cache = _factory.GetCache("default");
And finally the code to add an item to the cache:
_cache.CreateRegion(region);
_cache.Put(key, value, new TimeSpan(0, timeToLive, 0), tag, region);
The solution to this issue was to increase the requestTimeout in the client web.config and remove the receiveTimeout setting.
The web.config now looks like:
<dataCacheClient requestTimeout="600000" channelOpenTimeout="12000" maxConnectionsToServer="1">
<localCache isEnabled="false" sync="TimeoutBased" ttlValue="300" objectCount="10000"/>
<clientNotification pollInterval="300" maxQueueLength="10000"/>
<securityProperties mode="None" protectionLevel="None" />
<transportProperties connectionBufferSize="131072" maxBufferPoolSize="568435456" maxBufferSize="183886080" maxOutputDelay="2" channelInitializationTimeout="60000" /> </dataCacheClient>
Hi guys I created a service using WCF but when I test my services some completed successfully why some is giving me the error below. Any Idea on how to solve these ? Thanks
An error occurred while receiving the HTTP response to http://localhost:8733/PortOperation/Operator_Service/ws. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)
at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.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)
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 IOperator_Service.GetAllUser(String ConnectionString)
at Operator_ServiceClient.GetAllUser(String ConnectionString)
Inner Exception:
The underlying connection was closed: An unexpected error occurred on a receive.
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
Inner Exception:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
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)
Inner Exception:
An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
There are many scenarios when this type of error occurs.
First
Check that have you provided proper [DataContract] and [DataMember]? if this is not provided then this type of error occurs. You have to write [DataContract] above the class which you pass in response, and write [DataMember] above the class member which goes into the client response.
eg.
[DataContract]
class Program
{
[DataMember]
public string Example{get;set}
}
Second
Check in the response if some minvalue of Data type is passed. That means some time data member is not initialized at that time it takes the minvalue.
e.g. minValue of int is '-2147483648' so at some time it cannot be serialized and throws an error.
If you want to trace this type of error then add the following code in your server-side web.config
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "D:\Traces.svclog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
I think it will help you.
I was able to solve the problem.
If you are using EF "code first"-approach and you want access to your data using WCF you should consider not enabling lazy loading using the "virtual" keyword in your poco-class because WCF serialization cannot serialize dynamic proxy data.
I am using WCF service in my client-server application and I am facing following error while communication between server and client.
Error Message =>> System.ServiceModel.CommunicationObjectAbortedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it has been Aborted.
Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()
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)
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 ServiceLib.ServiceCallbackInterfaces.IHostServiceCallback.SendEventAndStatus(String message, Boolean isBackupGenerated)
at ServiceLib.Services.DriversService.objDriver_EventReceived(Object sender, EventReceivedEventArgs e)
Application Scenario : Client is getting data from server through WCF service and using nettcp binding. Server is connected with real device and generating 20-30 events every seconds. Generated events are pushed as string message to all connected clients using callback interface of WCF. It's working fine if client have no any process load (just receive event and display). But it gives error when we do some loading process at client side and busy for some time.
Note: I had already set maximum all timeouts in nettcp binding as below, but still problem not solved.
NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.None);
tcpBinding.MaxBufferPoolSize = 2147483647;
tcpBinding.MaxReceivedMessageSize = 2147483647;
tcpBinding.MaxBufferSize = 2147483647;
tcpBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
tcpBinding.ReaderQuotas.MaxDepth = 2147483647;
tcpBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
tcpBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
tcpBinding.ReaderQuotas.MaxArrayLength = 2147483647;
tcpBinding.SendTimeout = TimeSpan.MaxValue;
tcpBinding.ReceiveTimeout = TimeSpan.MaxValue;
tcpBinding.ReliableSession.InactivityTimeout = TimeSpan.MaxValue;
Please guide me is there any other settings required related to communication channel or binding ?
UPDATE : Error thrown by svc tracer :
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>131075</EventID>
<Type>3</Type>
<SubType Name="Error">0</SubType>
<Level>2</Level>
<TimeCreated SystemTime="2011-09-30T08:37:01.5691715Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
<Execution ProcessName="ServerUtility" ProcessID="2396" ThreadID="5" />
<Channel />
<Computer>TEST</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error">
<TraceIdentifier>http://msdn.microsoft.com/it-IT/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier>
<Description>Throwing an exception.</Description>
<AppDomain>ServerUtility.exe</AppDomain>
<Exception>
<ExceptionType>System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>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 '10675199.02:48:05.4775807'.</Message>
<StackTrace>
at System.ServiceModel.Channels.SocketConnection.EndRead()
at System.ServiceModel.Channels.DelegatingConnection.EndRead()
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
at System.ServiceModel.Channels.SocketConnection.FinishRead()
at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead)
at System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32 error, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>
<ExceptionString>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 '10675199.02:48:05.4775807'. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
--- End of inner exception stack trace ---</ExceptionString>
<InnerException>
<ExceptionType>System.Net.Sockets.SocketException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>An existing connection was forcibly closed by the remote host</Message>
<StackTrace>
at System.ServiceModel.Channels.SocketConnection.EndRead()
at System.ServiceModel.Channels.DelegatingConnection.EndRead()
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)
at System.ServiceModel.Channels.SocketConnection.FinishRead()
at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead)
at System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32 error, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>
<ExceptionString>System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host</ExceptionString>
<NativeErrorCode>2746</NativeErrorCode>
</InnerException>
</Exception>
</TraceRecord>
</DataItem>
</TraceData>
<System.Diagnostics xmlns="http://schemas.microsoft.com/2004/08/System.Diagnostics">
<LogicalOperationStack></LogicalOperationStack>
<Timestamp>4730654290080</Timestamp>
</System.Diagnostics>
</ApplicationData>
</E2ETraceEvent>
As you mentioned in your question, you have set all timeouts to maximum. So as per my opinion, there should be problem in InstanceContextMode you defined. Which mode you defined in your service ? PerSession, PerCall or Single. There might be PerCall you defined and calling service by same object (globally declared object of service) then it's possible to channel come in fault state or connection disconnected.
So If you defined PerSession mode then use single object (Globally declared) from client side to get data from service. If you defined PerCall option then create new object every time.
Hope this help to you. Please feel free to ask any doubt...