WCF服务连接问题 - 也许是安全性?

时间:2009-03-01 23:58:59

标签: .net wcf security

我正在尝试调试WCF服务。这个客户端过去能够连接,但现在我无法连接。 该服务部署到服务器。我可以使用浏览器访问服务器的服务页面,然后查看生成客户端的说明。 我使用svcutil重新生成了客户端代理和配置文件。

客户端启动,但第一次调用服务会在1分钟超时后返回错误。同时,我可以附加到服务器上运行的服务并在那里单步执行代码。我可以看到我的客户从未注册过。此调用的服务器代码中的断点不会被命中。出于某种原因,我无法进入服务器代码(但我可以将调试器附加到服务器上的服务):

Unable to automatically step into the server. 
Connecting to the server machine 'shuttle' failed. 
Please install the Visual Studio 2008 Remote Debugger on the 
server to enable this functionality.

远程调试器已安装并正在运行或正在运行。 我在长时间超时后收到此错误:

Client is unable to finish the security negotiation within the 
configured timeout (00:00:00).  The current negotiation leg is 1 (00:00:00).

当我设置安全模式=无,并增加超时时,错误将变为

The open operation did not complete within the allotted timeout of 00:02:00.
The time allotted to this operation may have been a portion of a 
longer timeout.

我没有运行任何防火墙,我看到请求在Ethereal的服务器上进入。我正在看TCP流,我不能说为什么谈判失败了。事件日志中没有任何相关内容。我正在失去动力,并希望得到一些暗示。

客户端app.config包含svcutil生成的部分:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsDualHttpBinding>
                <binding name="WSDualHttpBinding_SportRadarDCS" 
                    closeTimeout="00:01:00" openTimeout="00:01:00" 
                    receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" 
                    hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" 
                    maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" 
                    useDefaultWebProxy="true">
                      <readerQuotas 
                       maxDepth="32" maxStringContentLength="8192"  
                       maxArrayLength="16384"
                       maxBytesPerRead="4096" 
                       maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" 
                       inactivityTimeout="00:10:00" />
                    <security mode="Message">
                        <message clientCredentialType="Windows" 
                           negotiateServiceCredential="true"
                           algorithmSuite="Default" />
                    </security>
                </binding>
            </wsDualHttpBinding>
        </bindings>
        <client>
            <endpoint
                 address="...."
                binding="wsDualHttpBinding" 
                    bindingConfiguration="WSDualHttpBinding_SportRadarDCS"
                    contract="SportRadarDCS" 
                    name="WSDualHttpBinding_SportRadarDCS">
                <identity>
                    <userPrincipalName value=".. my domain user ..." />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

1 个答案:

答案 0 :(得分:8)

查看WCF跟踪。如果您在服务主机上运行它,它将为您提供正在发生的单个WCF调用,并且应该足以让您找出配置的哪些部分已被打包。

我特意发现连接问题,这是解决原因的唯一方法。

MSDN on WCF Tracing your application

A good tutorial to help you understand the MSDN