17

I have a client application developed in .net seding a request to wcf service and supposed to send reponse .if execution time with in 1 minute,there is no error,if it exceeds 1 minute the error is

Inner exception: This request operation sent to net.tcp://localhost:18001/PitToPort/2008/01/30/StockpileService/tcp did not receive a reply within the configured timeout (00:01:00).
The time allotted to this operation may have been a portion of a longer timeout. This may be because the service is still processing the operation or because the service was unable to send a reply message. Please consider increasing the operation timeout (by casting the channel/proxy to IContextChannel and setting the OperationTimeout property) and ensure that the service is able to connect to the client

How to increase the time out and how? What is the best solution?

9 Answers 9

64

Be careful, this error message is a boilerplate string WCF sends when it doesn't have a clue what happened. It really means "mmh something went wrong in the chain but I'm not really sure what, so, here's some trivia about the configuration, do what you want with it".

MOST OF THE TIME when you get this message it has nothing to do with actual timeouts. It can be quotas (number of objects in the graph, overall size, array length) or something that went wrong server-side, between the time your service method returned a result and the actual bytes were sent over the wire. So, you should check your configuration settings (and not the timeout, except if you had to actually wait for one minute to get the error. If you got the error straight away, it has nothing to do with timeouts whatsoever).

This useless message is on top of my list of WCF annoyances.

2
  • 1
    Am talking out of Practical Experience and 1. the isuue is Timeout(wcf service processing in database server the corresponding procedure is taking more than 2 min) 2. the response returmns list[] size 400 elements,if we try to return 100 elements No error,if we return full list then its thrown error,then we realaize this is because of buffer size. If we are not increase the time in server side still its fails,so in my case have to do both
    – rmdussa
    Jun 3, 2009 at 2:26
  • I agree, it is boilerplate as you'll find different solutions worked for some and not others. For me, it was a console app I was starting up to test a non-WCF (java based) service. It took millseconds in SoapUI, but would take a minimum of 3 seconds and sometimes would timeout using my app. I think Connection Pools and other stuff may have needed time to initialize when starting the app. I set my SendTimeout to 5 minutes and it's fine now. Note: Multiple calls to the service within the app (after launching it) happened in milliseconds. c.Endpoint.Binding.SendTimeout = new TimeSpan(0, 5, 0);
    – MikeTeeVee
    Jul 25, 2013 at 15:50
15

The timeout is called "sendTimeout" and you can configure it on your binding section in your config file, or in code - your choice.

config:

  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding sendTimeout="00:03:00" />
      </netTcpBinding>
    </bindings>

This will set the timeout to 3 minutes.

Marc

9
  • 2
    do we need to write on both ends(clien config and server config)?
    – rmdussa
    May 28, 2009 at 6:07
  • I have tried with "00:30:00" still I get the error 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:29:57.8030000'.
    – rmdussa
    May 28, 2009 at 6:29
  • 1
    but really it is not wait 30 minutes,it fails with in 1 minute
    – rmdussa
    May 28, 2009 at 6:29
  • 2
    You only need to add this on the client side, UNLESS your server itself then also makes calls out to other services.
    – marc_s
    May 28, 2009 at 9:46
  • 4
    check my answer. It probably has nothing to do with timeouts. This exception message is EVIL pure and simple. Jun 3, 2009 at 0:27
5

I have add the following code to the Service app code

system.transactions  
    defaultSettings timeout="00:30:00" 

with this code the service will wait 30 minutes to get process done in database server and increase the

maxBufferSize="2147483647"  
maxReceivedMessageSize="2147483647"  
maxBufferPoolSize="2147483647" 

in client binding attributes, then it works fine.

Problem :Service is sending response but the client buffersize was less previously,I increased to maximum buffer size.

1
  • 2
    It looks like this would allow a 2GB request to tie up a thread for 30 minutes, making it an easy target for DDOS.
    – Webveloper
    Jun 24, 2013 at 21:26
2

I experienced this same error. Specifically, the exception that I received was:

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:09:59.9940000'.

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:09:59.9940000'.

System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

The cause of my problem was due to the size of the message that was being sent from my WCF Client to the WCF Host. Apparently, the size of the message was too large.

To fix the problem, I changed the hosts Web.Config maxReceivedMessageSize attribute from 2097152 to 8000000 and the error no longer persisted.

Here's the Web.Config's attribute I'm referring to:

<netTcpBinding>
<binding name="NetTCPBinding" maxReceivedMessageSize="8000000">
....
</binding>
</netTcpBinding>

The 8M message size that I chose was based on how large I "think" the message size is. I don't know of a way to explicitly determine the size of the actual WCF message that gets passed from the client to the host.

1

Check this out, for similar type of Error u have to set OperationTine out property http://www.codeproject.com/KB/WCF/WCF_Operation_Timeout_.aspx

1
  • 1
    In short: Cast the object returned from ChannelFactory<T>.CreateChannel() - which you normally invoke your operations on - to IContextChannel (yes, that works) and set the OperationTimeout property on that.
    – ygoe
    Apr 5, 2013 at 17:24
0

If you know why the server is taking more than a minute to respond to the client, then you should extend the OperationTimeout of the channel (as it says in the error message).

Check out this, including a code sample at the end: http://final-proj.blogspot.com/2009/09/wcf-timeouts.html

Good luck.

0

Here is a far simpler solution... just set the property directly on the current ClientBase. In other words, first add a service reference, initalize it, then set the property "InnerChannel.OperationTimeout"

NetUtilsWCF.SMTPDiagClient sClient = new NetUtilsWCF.SMTPDiagClient();

sClient.InnerChannel.OperationTimeout = new TimeSpan(0, 5, 0);

-1

I got the same exception when using callback.It works in local test(the client and service program are running in the same machine) but not work in user environment(the service program runs in winserver 2008). The server code has executed in according to the log.I think it's because of environment or authority problem but have no idea how to handle.

-2

If you are facing the problem after correcting the config file then you may need to check this attribute. "OperationContract(IsOneWay:=True)". If you miss IsOneWay:=True attribute it may cause this problem.

2
  • 1
    Totally not applicable, used for methods that don't return anything! Jan 11, 2012 at 22:29
  • As the top commenter states 'this error message is a boilerplate string WCF sends when it doesn't have a clue what happened', so one can expect to receive it for reasons unrelated to timeout settings. So it maybe at least somewhat applicable, as it was for Asokkumar.
    – dtwk2
    Oct 25, 2021 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.