WCF Timeout Longer than Timeout Value Set - wcf

Scenario: WCF service is running. Client is attempting to connect to it and use a method on the service. Service hangs for 2-3 minutes before returning a timeout.
All timeout values are set to be 10 seconds.
binding.CloseTimeout = TimeSpan.FromSeconds(_timeout);
binding.OpenTimeout = TimeSpan.FromSeconds(_timeout);
binding.SendTimeout = TimeSpan.FromSeconds(_timeout);
binding.ReceiveTimeout = TimeSpan.FromSeconds(_timeout);
Additionally the client has its InnerChannel.OperationTimeout set to TimeSpan.FromSeconds(_timeout) as well.
_timeout comes from the app.config file and is the value "10".
What I expect is that if there is a timeout that it takes 10 seconds to resolve, and not 120-180 seconds, which is what it is doing now.
The connection appears to be fine, its calling the method that intermittently fails and times out 120-180 seconds later.
Upon trying to send the command immediately after the timeout (repeating the call basically) it sends and receives just fine.
What am I missing here? What else needs set to make sure the client is not sitting for 2-3 minutes before timing out?
All articles that I am finding deal with these five timeout values (Close, Open, Send, Receive, and Operation).
binding is of type BasicHttpBinding.

It appears that both service side and client side require these timeouts. There was no timeout value placed on the service end. Once placed, the problem appears to have reconciled itself.

Related

Has anyone seen WCF report that it had timedout after waiting 15min but really had only been working for a few seconds

getting this error message in the wcf client log
The HTTP request to
'http://blah.svc'
has exceeded the allotted timeout of 00:15:00. The time allotted to
this operation may have been a portion of a longer timeout.
followed by
The request channel timed out while waiting for a reply after
00:14:59.9979998. Increase the timeout value passed to the call to
Request or increase the SendTimeout value on the Binding. The time
allotted to this operation may have been a portion of a longer
timeout.
However the service call had been made less than a minute before this. Any ideas as to what could cause this misreported timeout?
It happens for more than one machine so I don't think it is http://www.andyfrench.info/2010/11/wcf-service-throwing-immediate-timeout.html
Setting the following timeouts
OpenTimeout, CloseTimeout = 30 seconds
ReceiveTimeout, SendTimeout = 15 minutes
Our server log shows the request as being successful. Before and after this there have been fully successful service calls. Its not a single particular method on the service either.

Closing of WCF service (ServiceHost) not as graceful as it seems

When I call serviceHost.Close(), even if I put a timeout value serviceHost.Close(TimeSpan.FromMinutes(10)), while it stops receiving messages, it seems one or two of my messages gets lost from time to time.
I want my service to stop in the middle of an operation, but process the rest of the messages already received. Is there a way to gracefully close the service while a message is still processing?
I already set the closeTimeout and receiveTimeout in the app.config to 10 minutes, also use RequestAdditionalTime(600000) but I still get this issue. It does not close in 10 minutes, rather 1 minute at max.
Binding I am using is netMsmqBinding.
EDIT:
I temporarily fixed the problem by adding a while statement in the ServiceBase method OnStop that if the process is not finish then it will keep looping. It seems like a dirty hack, but it works for now. Let me know if there's a cleaner way to end it gracefully.

The request channel timed out while waiting for a reply after 00:01:00 error for autocompleteextender

I get this error.
The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
I am using an automcompleteextender which calls a [webmethod] which in turn calls a WCF service. The problem is when i enter 3 letters at a time the service call freezes. The extender never works. No other autocompleteextender works on the page later.
I have already tried setting sendTimeout and maxReceivedMessageSize. It doesnt help.
Please provide a word around.
Well i solved the issue. It was really strange on how it got solved.
I had to change the binding from WsHttpBinding to BasicHttpBinding
Everything else remained the same. It was just the Binding

How to implement ServiceStack Redis Client with timeout

We are implementing a pattern where our client checks to see if a document exists in Redis, and if it does not, we then fetch the data from the database.
We are trying to handle a case where the Redis server is down or unreachable so we can then immediately fetch from the database.
However, when we test our code by intentionally taking down the Redis server, the call to Redis via the ServiceStack client does not timeout for approximately 20 seconds.
We tried using the RedisClient .SendTimeout property to various values (1000, 100, 1), but the timeout always happens after approx 20 seconds. We also tried using the .Ping() method but have the same problem.
Question: how can we handle the scenario where the Redis server is down and we want to switch to a DB fetch more quickly?
I had a similar problem sending e-mail: sometimes there's no answer and the build-in timeout (of SmtpClient) does nothing. Eventually I'd get a timeout which I believe comes from the underlying TCP/IP layer. I'd set the timeout in the client a little shorter than the "brutal timeout" on Task.Wait.
My solution was to wrap the call in a Task, and use a timeout on that:
// this special construct is to set a timeout (the SmtpClient timeout does not seem to work)
var task = Task.Factory.StartNew(() => SendEmail(request));
if (!task.Wait(6000))
Log.Error("Could not send mail to {0}. Timeout (probably on TCP layer).".Fmt(request.To));
Maybe something similar would work for you, just replace the SendEmail with a method that does the Redis thing.
You should not rely on the redis server to tell you how long the request should wait before flipping to plan B. Put this logic in the code actioning the request so that it is independent of how the redis server is set up

Timeout Question about Invoking a Remote WCF Service

When I invoke a remote WCF service I get the following timeout:
The request channel timed out while waiting for a reply after 00:00:59.2810338. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
Please note that I am sending a single object which is LOADED with a LOT of data.
Any ideas how to fix this issue and is this a problem on the client (ME) or the Server.
Given the size, have you tried increasing your maxBufferSize/maxReceivedMessageSize in your binding?
Chunk your data into smaller pieces if possible and try again. This is a server setting that you will need to work around or request that the service provider increase it.
Without a stack trace I'm can't be 100% sure, but I'm relatively certain this is a client side exception. If you know it's going to take more than a minute to send the data all you need to do is change the sendTimeout on your binding to be whatever amount of time you need it to be.