1

我有一个托管的 WCF 服务。服务调用需要 30 秒或超过几分钟(但少于 10 分钟)来根据业务需求执行其处理。当客户端在代理后面并且服务器端的处理时间大于 1 分钟时,我遇到了问题。如果处理时间少于 1 分钟,则调用成功,没有任何问题。这表明通过代理与服务器的连接没有问题。但是,问题更多在于代理服务器的超时。

我得到以下异常

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

服务器堆栈跟踪:System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage信息)

在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 在 ConsoleApplication1.ServiceReference1 处的 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)。 IMyService.GeneratePackage(Guid clientId) 在 ConsoleApplication1.ServiceReference1.MyClient.GeneratePackage(Guid clientId) 在 F:\Code\Samples\ConsoleApplication1\ConsoleApplication1\Service References\ServiceReference1\Reference.cs:第 398 行在 ConsoleApplication1.Program.Main(String [] args) 在 F:\Code\Samples\ConsoleApplication1\ConsoleApplication1\Program.cs:line 26

我的配置部分看起来像

<system.serviceModel>
    <diagnostics>
        <messageLogging logEntireMessage="true" logMalformedMessages="true"
            logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
    </diagnostics>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IMyService" closeTimeout="00:10:00"
                openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="20000000"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="200000000"
                    maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="None">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        establishSecurityContext="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://TestServer.abc.co.za:8432/TestManager/MyService"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
            contract="ServiceReference1.IMyService" name="WSHttpBinding_IMyService">
            <identity>
                <dns value="TestServer.abc.co.za" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

我尝试了以下选项:

1) 实现 MessageInspector 并将“Keep-Alive”设置为“2000000”。2) 通过 Fiddler 检查请求和响应,查看 HTTP/1.1 504 Connection Timed Out

我的理解是,即使所有超时都设置在 WCF 服务级别,代理也不会等待超过一分钟。

如何确保代理等待 WCF 服务调用返回?

如果我能得到解决这个问题的意见,我将不胜感激。

4

0 回答 0