1

下面在服务器端的 Web.Config 中提到。

<bindings>
    <wsHttpBinding>
        <binding name="NewBinding0" closeTimeout="00:50:00" openTimeout="00:50:00" sendTimeout="00:50:00" receiveTimeout="00:50:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
            <reliableSession enabled="true" />
            <security mode="None">
                <transport clientCredentialType="None" />
                <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="false" />
            </security>
        </binding>
    </wsHttpBinding>
</bindings>

同样在客户端,我提到了以下设置。

WSHttpBinding binding = new WSHttpBinding();
//binding.ReaderQuotas.MaxArrayLength = 10485760;
//binding.MaxReceivedMessageSize = 10485760;
binding.Security.Mode = SecurityMode.None;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
binding.Security.Message.EstablishSecurityContext = false;
//binding.Security.Message.NegotiateServiceCredential = true;
binding.ReliableSession.Enabled = true;
binding.ReaderQuotas.MaxArrayLength = 2147483647;
binding.ReaderQuotas.MaxDepth = 2147483647;
binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
//binding.MaxReceivedMessageSize = 20000000;2147483647
binding.MaxReceivedMessageSize = 2147483647;
//binding.MaxReceivedMessageSize = Int32.MaxValue;
binding.ReaderQuotas.MaxStringContentLength = 2147483647;
//binding.MaxBufferPoolSize = 20000000;
binding.MaxBufferPoolSize = 2147483647;
//binding.MaxBufferPoolSize = Int32.MaxValue;
binding.ReaderQuotas.MaxArrayLength = 2147483647;
binding.ReaderQuotas.MaxDepth = 2147483647;
binding.SendTimeout = TimeSpan.FromMinutes(50);
binding.CloseTimeout = TimeSpan.FromMinutes(50);
binding.OpenTimeout = TimeSpan.FromMinutes(50);
binding.ReceiveTimeout = TimeSpan.FromMinutes(50);

//EndpointIdentity.CreateUpnIdentity("user@domain");
ChannelFactory<IDBSyncContract> factory = new ChannelFactory<IDBSyncContract>(binding, new EndpointAddress(endPointURL));
dbProxy = factory.CreateChannel();
this.dbProxy = dbProxy as IDBSyncContract;

我收到上述错误。

是否对 wsHttpBindings 有任何顾虑。

4

1 回答 1

2

您的问题是该服务正在消耗主机上的所有可用内存。我建议您删除所有配置更改并将配置恢复为 WCF 默认值。Microsoft 选择这些默认值是为了在平均 WCF 服务中获得最佳性能,并且您应该仅在证明需要这样做时更改它们。

我建议默认值的唯一例外是 themaxReceivedMessageSizemaxBufferSize值。我将从 262,144 字节开始。如果您在任何这些设置中遇到特定异常,则仅更改受影响的设置。

如果您在将设置提升到最大整数后仍然遇到问题,请考虑更改您的服务设计以在正常配置设置中成功调用。尽可能接近 WCF 默认值将为您的服务提供最佳的整体性能。

于 2012-10-25T13:57:53.370 回答