简体   繁体   English

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

[英]WCF service using duplex channel in different domains

I have a WCF service and a Windows client. 我有WCF服务和Windows客户端。 They communicate via a Duplex WCF channel which when I run from within a single network domain runs fine, but when I put the server on a separate network domain I get the following message in the WCF server trace... 它们通过Duplex WCF通道进行通信,当我在单个网络域中运行时,该通道运行良好,但是当我将服务器置于单独的网络域中时,在WCF服务器跟踪中会收到以下消息...

The message with to 与的讯息

'net.tcp://abc:8731/ActiveAreaService/mex/mex' cannot be processed at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher. 由于EndpointDispatcher上的AddressFilter不匹配,因此无法在接收方处理'net.tcp:// abc:8731 / ActiveAreaService / mex / mex'。 Check that the sender and receiver's EndpointAddresses agree. 检查发送方和接收方的EndpointAddresses是否一致。

So, it looks like the communication just work in one direction (from client to server) if the components are in two separate domains. 因此,如果组件位于两个单独的域中,则通信似乎仅朝一个方向(从客户端到服务器)工作。

The Network domains are fully trusted, so I'm a little confused as to what else could cause this? 网络域是完全受信任的,因此对于造成此问题的原因我有些困惑。

Server app.config 服务器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>

but I also add an end point programmatically in Visual C++ 但是我还以编程方式在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

Client app.config 客户端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>

Any help is appreciated! 任何帮助表示赞赏!

Cheers 干杯

If I remember correctly, the callback channel actually occurs on something sort of silly, like port 80. Looking at your choice of address, I would wager there is a firewall in between your two machines and you've explicitly opened a port. 如果我没记错的话,回调通道实际上是在某种愚蠢的东西上发生的,例如端口80。考虑到您选择的地址,我认为两台计算机之间存在防火墙,并且您已明确打开了端口。 You'll likely have to open port 80. 您可能必须打开端口80。

I think you can configure this using the clientBaseAddress property of the binding you are using if port 80 is not your cup of tea. 我认为如果端口80不是您可以使用的话,您可以使用绑定的clientBaseAddress属性进行配置。

Let us know how things went. 让我们知道事情的发展。

This is actually my question posted by one of my collegues, odd I know don't ask, I've checked the ports that are being used for the callback channel and they seem to be randomly generated within a certain range. 这实际上是我的一位同事发布的问题,奇怪的是我不问,我已经检查了用于回调通道的端口,它们似乎是在一定范围内随机生成的。 So far I've seen 3501, 4595 and a few others, so I've ruled out the port being the issue.. 到目前为止,我已经看到3501、4595和其他一些端口,因此我已经排除了端口问题。

Any other thoughts? 还有其他想法吗?

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

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