简体   繁体   English

wsDualHttpBinding无法在WPF客户端的网络外部工作

[英]wsDualHttpBinding not working outside network with WPF Client

I was trying to implement a DuplexCommunication between WPF and WCF, the communication is working good when test internally, with in the network, when we tried to access this outside network after publishing it outside, we are able to access the service thru web browser, but the WPF client is giving error, when we try to open the connection. 我正在尝试在WPF和WCF之间实现DuplexCommunication,在内部进行测试时,通信在网络中运行良好,当我们在外部发布该网络后尝试访问该外部网络时,我们可以通过网络浏览器访问该服务,但是当我们尝试打开连接时,WPF客户端给出了错误。 below are the configuration on both Server and Client side. 以下是服务器端和客户端端的配置。 Server: 服务器:

  <wsDualHttpBinding>
    <binding 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="None" />
    </binding>
  </wsDualHttpBinding>

  <service behaviorConfiguration="DuplexServices.DuplexServiceBehavior" name="DuplexServices.DuplexService">
    <endpoint address="dual" binding="wsDualHttpBinding" contract="DuplexServices.IDuplexService" >
     </endpoint>
   </service>

Client: 客户:

<wsDualHttpBinding>
            <binding name="WSDualHttpBinding_DuplexService" 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="None">
                </security>
            </binding>
        </wsDualHttpBinding>

     <client>
    <endpoint address="http://XXX.com/DuplexServices/DuplexService.svc/dual"
            binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_DuplexService"
            contract="DuplexServiceeReference.DuplexService" name="WSDualHttpBinding_DuplexService">
                    </endpoint>
     </client>

I have tried giving 'baseAddresses' and 'identity' with dns value on server side, also tried giving clientBaseAddress on client side, but still it wont work outside the network. 我曾尝试在服务器端使用dns值提供“ baseAddresses”和“ identity”,也尝试在客户端上提供clientBaseAddress,但仍无法在网络外部工作。

always getting timeout error when trying to open the duplex connection from WPF application: Error: "The open operation did not complete within the allotted timeout of 00:00:09.4911018. The time allotted to this operation may have been a portion of a longer timeout." 尝试从WPF应用程序打开双工连接时,总是收到超时错误:错误:“打开操作未在分配的超时时间00:00:09.4911018内完成。分配给该操作的时间可能是较长超时的一部分”。

I think there is something wrong on the config part, but not sure what it is, any help on this much appreciated . 我认为config部分有问题,但不确定是什么,对此非常感谢。

Thanks. 谢谢。

WsDualHttpBinding is not suitable for crossing firewalls - it requires the server open a connection to the client, by default on random address on port 80. The port used can be configured by the clientBaseAddress on the binding but still requires the fire wall to allow inbound connections which, you would hope, the network admins would prevent. WsDualHttpBinding不适用于穿越防火墙-默认情况下,它要求服务器打开与客户端的连接,默认为端口80上的随机地址。所用的端口可以由clientBaseAddress在绑定上进行配置,但仍需要防火墙允许入站连接您希望网络管理员可以阻止。 If you want to do duplex work in WCF then you should use NetTcpBinding which uses a single outbound connection and the callbacks are performed over this connection 如果要在WCF中进行双工工作,则应使用NetTcpBinding,它使用单个出站连接,并且回调是通过此连接执行的

I blogged about this here 我在这里写了这个

Is port 80 open on the client to accept incoming connections, and properly port forwarded through any NAT routers? 客户端上的端口80是否打开以接受传入连接,并且端口是否已通过任何NAT路由器正确转发? Dual HTTP Bindings require the server to be able to open a second HTTP connection to the client, and on the Internet (off the LAN) that almost always fails due to firewalls and home routers. 双重HTTP绑定要求服务器能够打开与客户端的第二个HTTP连接,并且在Internet(LAN上)上几乎总是由于防火墙和家庭路由器而失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM