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. 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>

客户:

<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>

我尝试过在服务器端提供baseAddresses和带有dns值的身份,也尝试过在客户端提供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."

我认为配置部分有问题,但不确定是什么,非常感谢在这方面的任何帮助。

谢谢

问题回答

WsDualHttpBinding不适合跨越防火墙-它要求服务器打开到客户端的连接,默认情况下在端口80上的随机地址上。使用的端口可以由绑定上的clientBaseAddress配置,但仍然需要防火墙来允许入站连接,您希望网络管理员会阻止这些连接。如果你想在WCF中进行双工工作,那么你应该使用NetTcpBinding,它使用单个出站连接,并且回调是通过这个连接执行的

我在博客上对此发表了评论此处

客户端上的端口80是否打开以接受传入连接,并通过任何NAT路由器正确转发端口?双HTTP绑定要求服务器能够打开与客户端的第二个HTTP连接,以及在由于防火墙和家庭路由器而几乎总是失败的互联网上(局域网外)。





相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签