WCF - Service host closing down after error - c#

We have a WCF service published in IIS on our local development machine. The service exposes several methods, one of them accepting an array of bytes as a parameter. When invoked we are getting an error when sending over 3MBs of data.
When invoked for the first time we get the following error: “An existing connection was forcibly closed by the remote host - WCF.”
If we invoke it again we then get this error: “An error occurred while receiving the HTTP response to http://[server]/service/method. 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.”
We know how to solve the error by increasing the buffersize and maxreceivedmessagesize in the binding and the maxrequestlength in the system.httpruntime.
The problem we find is that the error is causing the service host to close down and stops accepting further requests.
We’d like to know why the error is causing the servicehost to close down.
I was under the impression that any exceptions caused by a request would return a faultexception but wouldn’t necessarily close the host. Any even if the host is closed on the next request it would open it again.
Could somebody shed some light on this?

Check the maxRequestEntityAllowed limit.
See:
http://www.iis.net/configreference/system.webserver/asp/limits
http://msdn.microsoft.com/en-us/library/ms524953%28v=vs.90%29.aspx

Related

Timeout on a WCF call, but getting an HTTP 500(64) error

I've an application (on production environment) that makes a lot of concurrent (multithreading) calls to WCF services (.Net Framework 4.0, SOAP BasicHttpBinding). Sometimes, the last request throws a TimeoutException:
System.TimeoutException: The request channel timed out while waiting for a reply after...
I can't reproduce it on a local envrionment, so it's difficult to apply changes to try. Anyway I've increased the timeout but the exception is throwing equally (later evidently). I've traced the server searching for inter-threading locks or Oracle locks, but I couldn't find anything.
I've activated internal code traces and I've deduced that the request didn't reach my server code, so, watching the IIS traces I've found an HTTP error ~2' after the request:
sc-status sc-substatus sc-win32-status time-taken
500 0 64 118265
But the timeout exceptions is thrown later depending on the wcf binding configuration. So I have two questions:
Why WCF is not catching that http error and remains waiting for response? I've searched for the error but I have high values on servicethrottling parameters.
Why the server is throwing that error without getting the server code not even an on an IDispatchMessageInspector I've implemented to log some data on request and response?

How can a slow internet on client side be a reason for server time out exception in asp.net?

I have a .Net application up and running.
We have had a fluctuating connection yesterday. While testing in such scenarios we had received multiple server time out exception emails like below.
Server Time Out
Type : System.Web.HttpException, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Message : Request timed out.
Source :
Help link :
WebEventCode : 3001
ErrorCode : -2147467259
Data : System.Collections.ListDictionaryInternal
TargetSite :
HResult : -2147467259
Stack Trace : The stack trace is unavailable.
Additional Info:
IMPORTANT: Above exception occurred while doing a ajax post by a button placed with in update panel.
My question here is why would a slow internet on client side raise such server time out exception?
Isn't server timeout exception is related to such cases where server cannot execute the request in underlying time mention in HttpRuntime setting? May be due to some lengthy operation or some long database execution which takes longer than the time mentioned in setting under HttpRuntime.
If server is not able to connect to the client due to clients fluctuating internet, then Client Disconnected exception would be raised which we did yesterday. But I am not able to conclude the reason for this server timeout exception.
I already know that increasing the execution timeout will fix the issue, but I have to provide technical explanation for the reason as to why such exception of Server Timeout raised.
My best guess here is that the ajax request would be doing some continuous communication with server for executing of single request server and would raise timeout exception if it does not receives some required further communication messages due to client's bad internet. I have search over internet for the same to support my guess but in vain.
Also to provide environmental details, there is a load balancer serving the request.
Any help would be highly appreciated.
It is because (as you write) the connection of client to server is slow, so if the server (or client) sending data to this server, connection can´t handle it, so you get timeout error, because the data can´t been transfered in defined time.
You also write, that this is caused by sending Ajax request, so maybe try to increase execusion timeout in web configuration file (web.config):
<httpRuntime executionTimeout = "number(in seconds)"/>
More about executionTimeout here and here about Ajax requests.
Firstly, I think the cause of this error is because of execution time required by your application request connecting with the remote server is exceeding the currently set ASP.NET request execution timeout value. As per the MSDN Exception Document, default value is set to 110 seconds, in that it is remarked like:
The ExecutionTimeout property indicates the maximum number of seconds
a request is allowed to execute before being automatically shut down
by ASP.NET.
So based on error detail with event code 3001 occurs because no response was received during the time-out period for a request. You can use IIS troubleshooting failed request mechanism to figure it out exact issue like any poor performance/deadlocks when making calls from your ASP.NET application.
Secondly, it is not related to user's internet connectivity issue otherwise you get exception with status like connection-closed or keep alive failure. See this article for detail. The browser is going to wait for a 60 minutes(which is very long period of time that server isn't going to answer any request)for server to response.
And at any case when the browser abandons any request, it is going to close the socket and you'll get an error page from the browser. You don't get anything related to sever-end.

Intermittent System.ServiceModel.CommunicationException

I have a console app that calls a WCF service to authorize scheduled credit card payments for a given store ID. Last night it called this service over 100 times and one of those calls, it got this error:
System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to [service url] 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. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
What brought this to our attention was that this store had it's first 100 transactions authorized but 43 were left not authorized (not attempted). The service method simply grabs all 143 and does a foreach loop on them, authorizing them 1 at a time. The method returns a boolean result wrapped in a custom object that can also return error info if necessary, but that object should be small and does not change size in respect to the amount of transactions processed. I mention that because I read one case where this exception occurred in responses over a certain size. But it my case, it seems that something happened before it even tried to return. The service stopped processing in the middle of looping at which point the client received this exception. Any ideas?

Channel TCP is already registered but with Infinite Loop

I have created TCP Client and Server using .Net remoting . When I call server from client i.e. at the line RemotingConfiguration.Configure("App.config", true);, I am getting error as
Remoting configuration failed with the exception 'System.Runtime.Remoting.RemotingException: The channel 'tcp' is already registered.
I have made all the settings in config file. To resolve this issue, I gave unique name to the client application. Now, I am not getting error but when I send any data from client to server,nothing happens at server or client end. If I closed the server, I get error in client application as remoting server closes the connection , which is proper behaviour. So the issue is why nothing happnes at client or server end.
RemotingConfiguration.Configure("App.config", true); line is not giving me any error, but server.Send("Hi") does not give any response back to the client. Nothing displays on server.

CommunicationException with 'not recognized sequence' message in WCF

I get a CommunicationException while using WCF service. The message is:
The remote endpoint no longer recognizes this sequence. This is most likely due to an abort on the remote endpoint. The value of wsrm:Identifier is not a known Sequence identifier. The reliable session was faulted.
The exception is thrown in a moment after a contract method was called. Before calling contract method the channel state is Opened. I restore my service client after catching this exception and for some time it works fine. But then this error occures again. It seems like some timeout is exceeded, but I can't understand which one exactly.
I use wsHttpBinding with reliableSession enabled. The InactivityTimeout is set to half an hour and I'm sure it's not exceeded, because exception is thrown earlier.
I solved the problem. The reason was RecieveTimeout on a server side. It was set to 1 minute, so after having no requests during 1 minute server used to close a channel, and when client tried to call a contract, channel was already crashed due to the timeout.
I found the solution after reading this article:
http://msdn.microsoft.com/en-us/library/system.servicemodel.reliablesession.inactivitytimeout.aspx
I received this error while setting up a new WCF service which returned a list of objects.
My understanding is that WCF services can only pass very simple objects back n forth.
So objects with anything other than public properties will not be transferable.
The object had a read only property doing a bit of logic.
Once I got rid of this, rebuilt, and updated the web references, the error went away.
Tip:
If you're returning a object and it has properties check the gets and sets of each one.
We had a problem around it.
I have seen this happen when an application pool gets recycled.
Look at the very last section of this blog about service recycling .

Categories

Resources