无法连接到远程WCF服务 - TimeoutException

时间:2012-12-19 08:12:11

标签: c# wcf

我之前曾要求question在尝试从远程计算机访问WCF服务时解决SecurityNegotiationException。由于ValtasarIII的回答,这个例外已得到解决。

现在我有一个不同的问题。我已在服务器上托管我的服务,并希望使用客户端应用程序连接到它。但是,当我尝试从客户端应用程序订阅服务时,没有任何反应,最后我得到了例外:

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

(如果需要,我可以共享堆栈跟踪)

虽然当我尝试测试服务是否正在运行时,我可以通过浏览器从客户端计算机成功访问它。

以下是我的配置:

服务 - web.config

<configuration>
  <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="wsHttpDual">
          <security mode="None">
            <message clientCredentialType="None" algorithmSuite="Default" />
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <protocolMapping>
      <add scheme="http" binding="wsDualHttpBinding" bindingConfiguration="wsHttpDual"/>
    </protocolMapping>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

客户端 - app.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <wsDualHttpBinding>
        <binding name="WSDualHttpBinding_ISampleContract" clientBaseAddress="http://95.138.188.232:8000/myClient/">
          <!--<security mode="Message">
            <message clientCredentialType="Windows" algorithmSuite="Default" />
          </security>-->
          <security mode="None">
            <message clientCredentialType="None" algorithmSuite="Default" />
          </security>
        </binding>
      </wsDualHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://95.138.188.232/autofxtools/service.svc"
          binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ISampleContract"
          contract="ISampleContract" name="WSDualHttpBinding_ISampleContract">
        <identity>
          <servicePrincipalName value="host/95.138.188.232" />
        </identity>
      </endpoint>

    </client>
  </system.serviceModel>
</configuration>

我已经找到了解决方案,但没有任何对我有用。服务配置似乎表明没有安全要求。但是,具有相同配置的客户端实际上与服务在同一台计算机上,但不能从远程计算机上运行。这是否意味着仍然存在Windows身份验证(根据wsDualHttpBinding的默认值)?如果是的话那么我哪里错了?

希望得到一些积极的反馈。

问候。

1 个答案:

答案 0 :(得分:2)

这可能是防火墙问题。我假设您在ISS中托管服务 - 您确定各自的端口是否已打开?当您尝试通过浏览器访问服务时会发生什么?

另外,我在德国论坛上读到以下内容:

  

Anscheinend tritt das Problem nur bei WsDualBinding auf,wenn der Port 80 belegt ist。   Gibt wohlkeineMöglichkeitdenPort mit Hilfe von ClientBaseAdresszuändern。   EinzigeMöglichkeitist hier wohl netTcpBinding。

用英语表示:

  

显然,当端口80已被占用时使用WsDualBinding会出现此问题。似乎没有办法使用ClientBaseAddress更改端口。唯一的方法似乎是使用netTcpBinding。

相关问题