Timeout for calling an asynchronous web service in C #

I use C # and created a proxy from ASP.NET asmx Web Service on the client side using the add web links feature ... VSTS 2008.

And I use the model of calling asynchronous methods (i.e., the AsyncXXX method is called, which will immediately return) and processes the complete event (I add an event handler to handle the full, even when the response is received from the server).

I find that if there is no response from the server for a long time, the full event will not be fired.

My questions:

  • Is the expected function, or my mistake, that if a response from the server after calling the AsyncXXX method does not trigger a full event handler?

  • Is there a way to assign a timeout value - so that I do not wait for the event handler to end indefinitely?

thanks in advance George

+3
source share
3 answers

In web.config you can set a timeout for your web service (you will also need to change it so that it is not in debug mode, if any). This should make it throw an exception that will lead to your completed event. Then you will need to check the exception to check if it failed or failed.

<system.web>
    <httpRuntime executionTimeout="120" />
</system.web>
+2
source

If you want your web service to never overheat, you can put this line in the web services class:

this.Timeout = System.Threading.Timeout.Infinite;
0
source

SoapHttpClientProtocol, , Timeout, WebClientProtocol. .

-1

Source: https://habr.com/ru/post/1703028/


All Articles