31

I've created one web service which is of asmx type. And I'm using my web service in the .net windows application.

Web method from the web service receives byte array conversion of the object & object of my class having different attributes in which i'm adding one xml file in the form of the string. When my string containing xml data increases then it gives me the "Time out" error while sending data to the the web service.

How to increase the timeout period of web service?

Ajay
  • 18,086
  • 12
  • 59
  • 105
Priyanka
  • 2,802
  • 14
  • 55
  • 88

3 Answers3

25

1 - You can set a timeout in your application :

var client = new YourServiceReference.YourServiceClass();
client.Timeout = 60; // or -1 for infinite

It is in milliseconds.

2 - Also you can increase timeout value in httpruntime tag in web/app.config :

<configuration>
     <system.web>
          <httpRuntime executionTimeout="<<**seconds**>>" />
          ...
     </system.web>
</configuration>

For ASP.NET applications, the Timeout property value should always be less than the executionTimeout attribute of the httpRuntime element in Machine.config. The default value of executionTimeout is 90 seconds. This property determines the time ASP.NET continues to process the request before it returns a timed out error. The value of executionTimeout should be the proxy Timeout, plus processing time for the page, plus buffer time for queues. -- Source

th1rdey3
  • 4,176
  • 7
  • 30
  • 66
MOH3N
  • 905
  • 9
  • 14
  • 6
    Note that the httpRuntime element goes here: ... – Ben Power May 18 '15 at 23:27
  • 2
    According to https://msdn.microsoft.com/en-us/library/e1f13641(v=vs.100).aspx the property is expressed in seconds, not milliseconds. – Sue Maurizio Apr 27 '16 at 14:10
  • 2
    Actually the client.Timeout is in milliseconds, as confirmed by intellisense and this article: https://msdn.microsoft.com/en-us/library/ff647786.aspx#scalenetchapt10_topic14 – Will May 17 '18 at 16:16
19

you can do this in different ways:

  1. Setting a timeout in the web service caller from code (not 100% sure but I think I have seen this done);
  2. Setting a timeout in the constructor of the web service proxy in the web references;
  3. Setting a timeout in the server side, web.config of the web service application.

see here for more details on the second case:

http://msdn.microsoft.com/en-us/library/ff647786.aspx#scalenetchapt10_topic14

and here for details on the last case:

How to increase the timeout to a web service request?

Community
  • 1
  • 1
Davide Piras
  • 43,984
  • 10
  • 98
  • 147
  • I used 2nd option & set the timeout property of the web service proxy class property but it throws an exception as `The underlying connection was closed: The connection was closed unexpectedly.` – Priyanka Sep 02 '11 at 11:31
3

In app.config file (or .exe.config) you can add or change the "receiveTimeout" property in binding. like this

<binding name="WebServiceName" receiveTimeout="00:00:59" />
user1012506
  • 2,048
  • 1
  • 26
  • 45