【问题标题】:Can not access WCF duplex from client无法从客户端访问 WCF 双工
【发布时间】:2012-01-19 16:24:02
【问题描述】:

我很困惑,不知道为什么我无法连接到我的 WCF !!!

详情:

我有一个双工 WCF,它在我的本地窗口中成功运行和工作。我将它托管在服务器(IIS - 服务器 2008 R2-STANDARD)中,并尝试连接,但出现错误似乎是一个安全问题,我可以从 Web 浏览器访问它并获取所有 xml....

在我的客户端中,我尝试按以下方式访问它:

this.myCallbackProxy = new MyCallbackProxy();
  InstanceContext cntx = new InstanceContext(myCallbackProxy);
  this.Proxy = new MyServiceClientProxy(cntx, "WSDualHttpBinding_I_BridgeWCFService");

//我也尝试添加以下,不行

this.Proxy.ClientCredentials.Windows.ClientCredential.UserName = "YY";
  this.Proxy.ClientCredentials.Windows.ClientCredential.Password = "PP";

以上通过,没有错误或异常。 那么:

try
{
this.Proxy.Open();
}
catch { -> here I get an exception:

例外:

打开操作未在分配的超时时间内完成 00:00:59.0849477。分配给此操作的时间可能是 较长超时的一部分。

我必须提到,我在同一个 IIS(非双工)中托管了另一个 WCF,具有相同的用户(服务器用户名),它运行良好。 (我对两者都使用相同的应用程序轮询,我也尝试创建新的应用程序池。

如果我从我想要运行应用程序的机器上通过 Web 浏览器中的链接“http://xx.xx.xx.xx/_Bridge/_BridgeWcfService.svc”,我会按预期获得 xml... .

服务和客户端都有 security = "none"

知道为什么我无法连接:(?

这里是 App.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
  <wsDualHttpBinding>
    <binding name="WSDualHttpBinding_I_BridgeWCFService" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646"
      messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483646"
        maxArrayLength="2147483646" maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00"/>
      <security mode="None"/>
    </binding>
  </wsDualHttpBinding>
</bindings>
<client>
  <endpoint address="http://xx.xx.xx.xx/_Bridge/_BridgeWcfService.svc" 
            binding="wsDualHttpBinding" 
            bindingConfiguration="WSDualHttpBinding_I_BridgeWCFService" 
            contract="_BridgeWcfServiceReference.I_BridgeWCFService" 
            name="WSDualHttpBinding_I_BridgeWCFService">
    <identity>
      <dns value="localhost"/>
    </identity>
  </endpoint>
</client>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
  </startup>
</configuration>

【问题讨论】:

  • 您的服务代理上还有哪些其他操作?你可以调用那些而不是 Open() 吗?
  • 不!!!,如果我在这里删除打开,任何操作都会抛出同样的异常:“打开操作没有在分配的超时时间 00:00:59.9939996 内完成。分配给这个操作的时间可能是较长超时的一部分。”

标签: wcf iis-7 duplex


【解决方案1】:

这听起来像是一个防火墙问题 - 一旦涉及防火墙,wsDualHttpBinding 就很容易崩溃,因为它试图打开从服务器到客户端的连接。我建议您使用 NetTcpBinding 进行双工通信。

我在博客上写过这个here

【讨论】:

  • 您好,我发现了问题,它只是测试应用程序端的防火墙在双工连接期间阻止了来自服务器的收入通道以进行回调。感谢 Richard Blewett 一直以来,我都在尝试使用服务器,而我的本地 PC 出现问题(我只是关闭了我的 PC 中的固件)并且它可以工作。
猜你喜欢
  • 2013-07-17
  • 2011-02-13
  • 1970-01-01
  • 2012-05-06
  • 1970-01-01
  • 2022-10-31
  • 1970-01-01
  • 1970-01-01
  • 2012-02-25
相关资源
最近更新 更多