WCF服务在不同域中使用双工信道

时间:2009-04-22 15:38:56

标签: .net wcf

我有一个WCF服务和一个Windows客户端。它们通过双工WCF通道进行通信,当我从单个网络域运行时运行良好,但是当我将服务器放在单独的网络域上时,我在WCF服务器跟踪中得到以下消息...

带有

的消息
  

'的net.tcp:// ABC:8731 / ActiveAreaService / MEX / MEX'   不能在接收器处理,   由于AddressFilter不匹配   EndpointDispatcher。检查一下   发送者和接收者   EndpointAddresses同意。

因此,如果组件位于两个独立的域中,那么通信就像是在一个方向(从客户端到服务器)工作。

网络域名完全受信任,所以我对其他原因可能会造成什么感到困惑?

服务器app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="JobController.ActiveAreaBehavior">
                    <serviceMetadata httpGetEnabled="false" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="JobController.ActiveAreaBehavior"
                     name="JobController.ActiveAreaServer">
                <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
                <host>
                    <baseAddresses>
                        <add baseAddress="net.tcp://SERVER:8731/ActiveAreaService/" />
                    </baseAddresses>
                </host>
            </service>
        </services>
    </system.serviceModel>

</configuration>

但我也在Visual C ++中以编程方式添加了一个终点

host = gcnew ServiceHost(ActiveAreaServer::typeid);

NetTcpBinding^ binding = gcnew NetTcpBinding();
binding->MaxBufferSize = Int32::MaxValue;
binding->MaxReceivedMessageSize = Int32::MaxValue;
binding->ReceiveTimeout = TimeSpan::MaxValue;

binding->Security->Mode = SecurityMode::Transport;
binding->Security->Transport->ClientCredentialType = TcpClientCredentialType::Windows;

ServiceEndpoint^ ep = host->AddServiceEndpoint(IActiveAreaServer::typeid, binding, String::Empty); // Use the base address

客户端app.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_IActiveAreaServer" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Transport">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://SERVER:8731/ActiveAreaService/"
                binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IActiveAreaServer"
                contract="ActiveArea.IActiveAreaServer" name="NetTcpBinding_IActiveAreaServer">
                <identity>
                    <userPrincipalName value="user@SERVERDOMIAIN.CLIENTDOMAIN.COM" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

感谢任何帮助!

干杯

2 个答案:

答案 0 :(得分:0)

如果我没记错的话,回调频道实际上发生在某种愚蠢的事情上,比如80号端口。看看你选择的地址,我敢打赌你的两台机器之间有一个防火墙,你明确地打开了一个端口。您可能需要打开80端口。

我认为你可以使用你正在使用的绑定的clientBaseAddress属性来配置它,如果端口80不是你的茶。

告诉我们事情的进展情况。

答案 1 :(得分:0)

这实际上是我的一个同事发布的问题,奇怪我知道不要问,我已经检查了用于回调频道的端口,它们似乎是在一定范围内随机生成的。到目前为止,我已经看过3501,4595和其他几个,所以我排除了端口问题..

还有其他想法吗?

相关问题