Search code examples
asp.netweb-servicesasmx

Webservice - executiontimeout and sendtimeout-receivetimeout-closetimeout and opentimeout difference?


I am trying to call the ASMX Web-Service.

Execution timeout is 600 i.e. 10 Minutes in Web.Config. Debug is false. While in Binding - I have written the following code:

<binding name="BasicHttpBinding_AdminService" openTimeout="00:20:00" closeTimeout="00:20:00" receiveTimeout="00:20:00" sendTimeout="00:20:00" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>

Though it is 20 Minutes for the Service -- I get Request Timeout in 10 Minutes from Server. I think the connection is getting cut off by Server in 10 Minutes.

I need to do it via Code only -- Without changing anything in Config. I don't want to change executiontimeout="600".

 <httpRuntime maxRequestLength="512000" executionTimeout="600" enableKernelOutputCache="false" />

I tried via Code with following ways:

var times = new TimeSpan(0, 20, 0);

1) ((IContextChannel)adminService.InnerChannel).OperationTimeout = new TimeSpan(0, 20, 0);

2)  adminService.InnerChannel.OperationTimeout = times;

3) adminService.Endpoint.Binding.SendTimeout = times;
   adminService.Endpoint.Binding.ReceiveTimeout = times;
   adminService.Endpoint.Binding.CloseTimeout = times;
   adminService.Endpoint.Binding.OpenTimeout = times;

4) adminService.ChannelFactory.Endpoint.Binding.CloseTimeout = times;
   adminService.ChannelFactory.Endpoint.Binding.OpenTimeout = times;
   adminService.ChannelFactory.Endpoint.Binding.ReceiveTimeout = times;
   adminService.ChannelFactory.Endpoint.Binding.SendTimeout = times;

But none helped. I also tried with Async Call, but no luck.

Is there anything I am missing?

I get the following in Response from Server:

ManagedPoolThread #8 06:52:05 ERROR Error in Feed via WebService
Exception: System.ServiceModel.ProtocolException
Message: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '

    <!DOCTYPE html>
    <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
    <!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
    <!--[if gt IE 8]><!-->
    <html class="no-js">
    <!--<![endif]-->

    <head>
        <!--[if !IE 9]><!-->
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <!--><![endif]-->
        <!--[if IE 9]><meta http-equiv="X-UA-Compatible" content="IE=9"><![endif]-->

        <meta charset="utf-8">

        <meta name="viewport" content="width=device-width, maximum-scale=1.0;">

        <link href="/bundles/Styles?v=i3oWdxitwv-nVHzTzh8-q4ehRZVNWjvCP15tgDwz3hI1" rel="stylesheet"/>




        <script src="/ISites/_Themes/ICom2013/_Design/js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>
        <script src="/ISites/_Themes/ICom2013/_Design/js/vendor/jquery-1.11.1.js"></script>
        <!-- Global for all sites-->

        <!-- Favicons for all'.
    Source: mscorlib

    Server stack trace: 
       at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
       at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at I.WCMS.BLL.AdminServiceReference.AdminServiceSoap.GetGenderFeed(GetGenderFeedRequest request)
       at I.WCMS.BLL.AdminServiceReference.AdminServiceSoapClient.I.WCMS.BLL.AdminServiceReference.AdminServiceSoap.GetGenderFeed(GetGenderFeedRequest request)
       at I.WCMS.BLL.AdminServiceReference.AdminServiceSoapClient.GetGenderFeed(String siteRoot, String securedString)
       at I.WCMS.Feeds.FeedTaskCommand.GenerateFeeds()

And I get the below exception on Server:

8672 07:02:05 ERROR Error in Admin Service for generating Feed
8672 07:02:05 ERROR Application error.
Exception: System.Web.HttpException
Message: Request timed out.

Why changing the Timeout in binding doesn't works?

Why Service Request get Timeout in 10 Minutes from Server?

Does executionTimeout be equal or greater than binding Timeout Settings?


Solution

  • Did lot of research and finally got the solution. As Webservice is located in another Directory, so the best solution is to create another web.config and change the executionTimeout for specific Service Request.

    Solution: Raise the time-out for a single webservice