【问题标题】:WCF showing timeout errorWCF 显示超时错误
【发布时间】:2011-05-23 20:43:06
【问题描述】:

我刚刚创建了一个 WCF 服务库。我创建了一个测试函数,并从 WCF 测试客户端调用了该测试函数。我在代码中设置了一个断点。控制到达断点并停在那里。现在我让控件在断点处停留一段时间,大约一分钟后得到以下错误消息

"调用服务失败。可能的原因:服务下线或无法访问;客户端配置与代理不匹配;现有代理无效。详细请参考堆栈跟踪。您可以尝试通过启动新代理、恢复到默认配置或刷新服务来恢复。”

错误详情: 00:00:59.9843750 后等待回复时请求通道超时。增加传递给 Request 调用的超时值或增加 Binding 上的 SendTimeout 值。分配给此操作的时间可能是较长超时的一部分。

服务器堆栈跟踪: 在 System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan 超时) 在 System.ServiceModel.Channels.ClientReliableChannelBinder1.RequestClientReliableChannelBinder1.OnRequest(TRequestChannel 通道,消息消息,TimeSpan 超时,MaskingMode maskingMode) 在 System.ServiceModel.Channels.ClientReliableChannelBinder1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode) at System.ServiceModel.Channels.ClientReliableChannelBinder1.Request(消息消息,TimeSpan 超时) 在 System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(消息消息,TimeSpan 超时) 在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan 超时) 在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出,TimeSpan 超时) 在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出) 在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime 操作) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)

在 [0] 处重新抛出异常: 在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg) 在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 类型) 在 ITrustmarkService.StartRobotProcess() 在 TrustmarkServiceClient.StartRobotProcess()

知道是什么原因造成的吗?

【问题讨论】:

    标签: wcf time


    【解决方案1】:

    这是来自MSDN 的示例 WCF 客户端配置:

     <bindings>
                <wsHttpBinding>
                    <binding name="WSHttpBinding_ISampleService" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00"
                        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                        allowCookies="false">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <reliableSession ordered="true" inactivityTimeout="00:10:00"
                            enabled="false" />
                        <security mode="Message">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                                algorithmSuite="Default" establishSecurityContext="true" />
                        </security>
                    </binding>
                </wsHttpBinding>
            </bindings>
    

    您应该将receiveTimeoutsendtimout 设置为适当的值,您可以在测试的配置文件中看到类似的配置。

    【讨论】:

    【解决方案2】:

    是的。默认情况下,WCF 服务配置了 1 分钟的响应超时。这意味着客户最多可以等待一分钟,如果他们在那段时间内没有得到响应,他们可以假设失败/没有响应。

    在您的情况下,您使用断点持有 WCF 服务来响应客户端的请求。等待一分钟后,客户端超时,不再等待。

    您可以从 WCF 服务的 .config 文件中增加此超时时间。

    【讨论】:

    猜你喜欢
    • 2010-12-14
    • 1970-01-01
    • 2015-06-02
    • 1970-01-01
    • 1970-01-01
    • 2011-01-28
    • 2013-06-21
    • 2011-06-16
    • 2011-04-22
    相关资源
    最近更新 更多