WCF双工通道和高内存使用率

时间:2017-03-14 11:43:53

标签: c# wcf

我有一个连接到自托管服务(ServiceA)的客户端,后者又使用WCF双工通道连接到另一个自托管服务(ServiceB),本质上服务A是一个很小的桥接器。从传递电话。服务A上的内存使用率非常高,并且在大约1000个连接处出现OutOfMemoryException崩溃。对我而言,这似乎并不高。

服务B似乎没有相同的问题,这让我觉得问题是在客户端创建双工通道时客户端配置如下所示。我写了一个简单的应用程序,模仿我的设置,根本不使用任何安全性,问题不存在。

端点:

<endpoint address="net.tcp://10.1.1.10:61002/SessionService/1/Federated" 
    behaviorConfiguration="ClientBehavior" 
    binding="CustomBinding" 
    bindingConfiguration="CustomBinding1" 
    contract="Company.Services.Common.Interfaces.ISessionService" 
    name="SessionService">
    <identity>
        <dns value="ServerName.Company.com" />
    </identity>
</endpoint>

结合:

<binding name="CustomBinding1" openTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="infinite">
    <transactionFlow />
    <reliableSession maxPendingChannels="20" inactivityTimeout="00:01:00" />
    <security authenticationMode="SecureConversation">
    <secureConversationBootstrap  authenticationMode="IssuedTokenForSslNegotiated" messageProtectionOrder="SignBeforeEncryptAndEncryptSignature">
        <issuedTokenParameters>
            <issuer address="https://IdentityServer.dev.local:443/IdentityServer/issue/wstrust/mixed/certificate" 
            binding="ws2007HttpBinding" bindingConfiguration="ws" />
            <issuerMetadata address="https://IdentityServer.dev.local:443/IdentityServer/issue/wstrust/mex" />
            <additionalRequestParameters>
                <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
                    <EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
                        <Address>http://Company.com/</Address>
                    </EndpointReference>
                </wsp:AppliesTo>
            </additionalRequestParameters>
        </issuedTokenParameters>
    </secureConversationBootstrap>
    </security>
    <binaryMessageEncoding>
        <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" 
        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    </binaryMessageEncoding>
    <tcpTransport maxBufferPoolSize="524288" maxReceivedMessageSize="5242880" 
        connectionBufferSize="8192" hostNameComparisonMode="StrongWildcard" 
        channelInitializationTimeout="00:01:00" maxBufferSize="5242880" 
        maxPendingConnections="20" maxOutputDelay="00:00:00.2000000" maxPendingAccepts="5" 
        transferMode="Buffered" listenBacklog="25" portSharingEnabled="true" teredoEnabled="false">
        <connectionPoolSettings groupName="default" leaseTimeout="00:00:00" idleTimeout="00:00:00" 
        maxOutboundConnectionsPerEndpoint="0" />
    </tcpTransport>
</binding>

行为:

<behavior name="ClientBehavior">
    <clientCredentials>
            <clientCertificate findValue="CN=ServerName.Company.com" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectDistinguishedName" />
        <serviceCertificate>
            <authentication certificateValidationMode="ChainTrust" revocationMode="NoCheck" />
        </serviceCertificate>
        </clientCredentials>
</behavior>

有没有人见过这样的东西?从内存跟踪中发现会发生很多(可能太多)会话安全性令牌缓存。我正在使用缓存的ChannelFactory来创建每个通道。我目前正在删除安全对话。

感谢。

0 个答案:

没有答案