:)
У меня странная проблема.
У меня есть собственная служба WCF, которая получает данные из базы данных и отправляет клиенту WPF.
Теперь я столкнулся с «фальшивой проблемой тайм-аута» («Сброс соединения через сокет. Это может быть вызвано ошибкой при обработке сообщения» ... и т. Д.), И я решил ее, исправляя тег безопасности (это было «нет»). Я исправил в "Транспорт".
Когда я выполнил его из среды VS2010 (скажем, без отладки и WcfSvcHost, но имея службу, запущенную в MMC и выполняющую программу из Проводника Windows), я снова столкнулся с той же идентичной ошибкой, на этот раз только при чтении большие объемы данных из базы данных (скажем, из таблицы строк по 25 тыс.).
Вот серверный файл приложения:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections></configSections>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="SvrBehavior" name="WCFSrvLib.WCFSrvLib">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8732/WCFSrvLib"/>
<add baseAddress="http://localhost:802/WCFSrvLib/mex"/>
</baseAddresses>
</host>
<endpoint bindingConfiguration="tcpSvrBinding" binding="netTcpBinding" contract="PhXSrvLib.IPhXSrvLib" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="tcpSvrBinding"
closeTimeout="00:05:00"
openTimeout="00:05:00"
receiveTimeout="00:05:00"
sendTimeout="00:05:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxConnections="10"
maxReceivedMessageSize="2147483647"
portSharingEnabled="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true"
inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SvrBehavior">
<serviceThrottling maxConcurrentCalls="50" maxConcurrentSessions="10" maxConcurrentInstances="50"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
... и вот фрагмент кода, в котором я создаю ChannelFactory и использую сервис
ChannelFactory<IWCFSrvLib> cf = new ChannelFactory<IWCFSrvLib>(new NetTcpBinding());
((NetTcpBinding)cf.Endpoint.Binding).CloseTimeout = new TimeSpan(0, 5, 0);
((NetTcpBinding)cf.Endpoint.Binding).OpenTimeout = new TimeSpan(0, 5, 0);
((NetTcpBinding)cf.Endpoint.Binding).ReceiveTimeout = new TimeSpan(0, 5, 0);
((NetTcpBinding)cf.Endpoint.Binding).SendTimeout = new TimeSpan(0, 5, 0);
((NetTcpBinding)cf.Endpoint.Binding).TransactionFlow = false;
((NetTcpBinding)cf.Endpoint.Binding).TransferMode = TransferMode.Buffered;
((NetTcpBinding)cf.Endpoint.Binding).TransactionProtocol = TransactionProtocol.OleTransactions;
((NetTcpBinding)cf.Endpoint.Binding).MaxReceivedMessageSize = Int32.MaxValue;
((NetTcpBinding)cf.Endpoint.Binding).MaxConnections = 10;
((NetTcpBinding)cf.Endpoint.Binding).MaxBufferPoolSize = Int32.MaxValue;
((NetTcpBinding)cf.Endpoint.Binding).MaxBufferSize = Int32.MaxValue;
((NetTcpBinding)cf.Endpoint.Binding).Security.Mode = SecurityMode.Transport;
((NetTcpBinding)cf.Endpoint.Binding).Security.Message.ClientCredentialType = MessageCredentialType.Windows;
((NetTcpBinding)cf.Endpoint.Binding).ReaderQuotas.MaxArrayLength = Int32.MaxValue;
((NetTcpBinding)cf.Endpoint.Binding).ReaderQuotas.MaxBytesPerRead = Int32.MaxValue;
((NetTcpBinding)cf.Endpoint.Binding).ReaderQuotas.MaxDepth = 32;
((NetTcpBinding)cf.Endpoint.Binding).ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue;
((NetTcpBinding)cf.Endpoint.Binding).ReaderQuotas.MaxStringContentLength = Int32.MaxValue;
((NetTcpBinding)cf.Endpoint.Binding).ReliableSession.Enabled = false;
((NetTcpBinding)cf.Endpoint.Binding).ReliableSession.InactivityTimeout = new TimeSpan(0, 10, 0); ;
((NetTcpBinding)cf.Endpoint.Binding).ReliableSession.Ordered = true;
foreach (OperationDescription op in cf.Endpoint.Contract.Operations)
{
DataContractSerializerOperationBehavior dataContractBehavior =
op.Behaviors[typeof(DataContractSerializerOperationBehavior)]
as DataContractSerializerOperationBehavior;
if (dataContractBehavior != null)
{
dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
}
}
Globs.catClient = cf.CreateChannel(new EndpointAddress("net.tcp://localhost:8732/WCFSrvLib"));
if (Globs.catClient == null)
throw new Exception("Unable to initialize server");
try
{
Globs.CatData = new List<CATData>(Globs.catClient.getData(out err, Globs.connsrv));
Globs.HandleError(err);
UpdateProgressBar();
}
catch (Exception e)
{
if (!NotifyError("Data", e.Message))
return false;
}
Есть несколько внутренних функций, поэтому они здесь не определены, но они не являются проблемой.
Обратите внимание, что все настройки канала были установлены при попытке найти решение этой проблемы.
Если вам нужно больше деталей или кода, просто спросите:)
Спасибо заранее,
Morenz.