【问题标题】:Webservice - executiontimeout and sendtimeout-receivetimeout-closetimeout and opentimeout difference?Webservice - executiontimeout 和 sendtimeout-receivetimeout-closetimeout 和 opentimeout 的区别?
【发布时间】:2015-11-30 17:10:05
【问题描述】:

我正在尝试调用 ASMX Web 服务。

执行超时为 600,即 Web.Config 中的 10 分钟。 调试是错误的。 在 Binding 中 - 我编写了以下代码:

<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>

虽然服务需要 20 分钟 - 我在 10 分钟内从服务器收到请求超时。我认为连接将在 10 分钟内被服务器切断。

我只需要通过代码来完成——无需更改 Config 中的任何内容。我不想更改 executiontimeout="600"。

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

我通过代码尝试了以下方式:

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;

但没有任何帮助。我也尝试过异步调用,但没有成功。

我有什么遗漏吗?

我在来自服务器的响应中得到以下信息:

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()

我在服务器上得到以下异常:

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.

为什么更改绑定中的超时不起作用?

为什么服务请求会在 10 分钟内从服务器获得超时?

executionTimeout 是否等于或大于绑定超时设置?

【问题讨论】:

  • 执行超时应采用以下格式 -executionTimeout = "HH:MM:SS" 。默认值为“00:01:50”(110 秒)。指定请求在被 ASP.NET 自动关闭之前允许执行的最大秒数。仅当编译元素中的调试属性为 False 时,此超时才适用。
  • 谢谢巴斯卡!但这不是解决问题的方法。
  • asp.net 进程的执行超时更多。绑定超时更多的是通道。因此,应增加绑定中的执行超时和接收超时以解决您的问题。
  • 如您所见——执行超时为 10 分钟,ReceiveTimeout 为 20 分钟,尽管我在 10 分钟内从服务器超时。所以你是说唯一的解决办法是改变executimeTimeout=1200而不是600?
  • 是的,您可以通过增加执行超时来尝试该路由

标签: asp.net web-services asmx


【解决方案1】:

做了很多研究,终于找到了解决方案。 由于 Webservice 位于另一个 Directory 中,因此最好的解决方案是创建另一个 web.config 并更改特定 Service Request 的 executionTimeout。

解决方案:Raise the time-out for a single webservice

【讨论】:

    猜你喜欢
    • 2010-09-29
    • 2014-01-20
    • 1970-01-01
    • 1970-01-01
    • 2011-11-25
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    • 2011-09-04
    相关资源
    最近更新 更多