在WCF服务中中止错误消息
本文关键字:错误 消息 服务 WCF | 更新日期: 2023-09-27 18:11:10
我有一个托管WCF的windows服务,其绑定配置如下:
<bindings>
<netTcpBinding>
<binding name="BindingReliableMessaging" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
<reliableSession enabled="true" inactivityTimeout="23:59:59"/>
</binding>
</netTcpBinding>
</bindings>
连接的客户端有类似的绑定。
我正在使用订阅方法发送消息,这是这个广播代码:
public void NotifyServer(EventDataType eventData)
{
lock (locker)
{
var inactiveClients = new List<string>();
// Broadcast to all the clients bar the one sending it
//
foreach (var client in clients)
{
if (client.Key != eventData.ClientName)
{
try
{
// Send the message to the current client
//
client.Value.BroadcastToClient(eventData);
}
catch (Exception)
{
// If we can't access the current clients callback method,
// we add them to the inactive clients list, as they've probably lost their connection.
//
inactiveClients.Add(client.Key);
}
}
}
if (inactiveClients.Count > 0)
{
// Remove any clients that we couldn't get to
//
foreach (var client in inactiveClients)
{
clients.Remove(client);
}
}
}
}
这已经使用了很长一段时间,只是最近发送的消息变得更大(现在大约113K),我得到以下错误消息:
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it has been Aborted.
我已经把所有的大小以及超时和客户端都最大化了。对原因有什么建议吗?
Rob按要求,以下是配置文件:
客户<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="ARIA.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="AriaClient.Log" />
<param name="AppendToFile" value="true" />
<lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="20" />
<maximumFileSize value="1MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date (#%property{pid}) [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IBroadcasterService" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
<reliableSession enabled="true" inactivityTimeout="23:59:59"/>
</binding>
<binding name="NetTcpBinding_IMathsEngineService">
<reliableSession enabled="true" />
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://MARSH:8080/MetricBroadcast" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IBroadcasterService" contract="MetricBroadcast.IBroadcasterService"
name="NetTcpBinding_IBroadcasterService">
<identity>
<userPrincipalName value="s_aria@racing.lc" />
</identity>
</endpoint>
<endpoint address="net.tcp://MARSH:8088/MathsEngine" binding="netTcpBinding"
bindingConfiguration="NetTcpBinding_IMathsEngineService" contract="MathsEngineService.IMathsEngineService"
name="NetTcpBinding_IMathsEngineService">
<identity>
<userPrincipalName value="s_aria@racing.lc" />
</identity>
</endpoint>
</client>
</system.serviceModel>
<connectionStrings>
<add name="AriaEntities" connectionString="metadata=res://*/Model.Aria.csdl|res://*/Model.Aria.ssdl|res://*/Model.Aria.msl;provider=System.Data.SqlClient;provider connection string="data source=MARSH'SQL2012;initial catalog=Aria;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
<add name="AMSEntities" connectionString="metadata=res://*/Model.AMS.csdl|res://*/Model.AMS.ssdl|res://*/Model.AMS.msl;provider=System.Data.SqlClient;provider connection string="data source=BIC-SVR-AMS1;initial catalog=ToroRossoAMS;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<applicationSettings>
<ARIA.Properties.Settings>
<setting name="MedusaPath" serializeAs="String">
<value>''bic-svr-aria01'Medusa</value>
</setting>
<setting name="LogHeartbeat" serializeAs="String">
<value>False</value>
</setting>
<setting name="UseRepository" serializeAs="String">
<value>False</value>
</setting>
</ARIA.Properties.Settings>
</applicationSettings>
</configuration>
服务<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MetricBroadcast.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="MetricBroadcast.Log" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="100" />
<maximumFileSize value="100MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
<connectionStrings>
<add name="MetricBroadcast.Properties.Settings.TargetConnectionString"
connectionString="Data Source=BIC-SVR-TSTARIA01'SQL2012;Initial Catalog=Aria;Persist Security Info=True;User ID=XXXXXX;Password=XXXX" />
</connectionStrings>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="BindingReliableMessaging" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"/>
<reliableSession enabled="true" inactivityTimeout="23:59:59"/>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="BroadcasterServiceBehavior" name="MetricBroadcast.BroadcasterService">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="BindingReliableMessaging" contract="MetricBroadcast.IBroadcasterService" />
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://BIC-SVR-TSTARIA01:8080/MetricBroadcast" />
</baseAddresses>
</host>
</service>
</services>
<!-- A behavior definition -->
<behaviors>
<serviceBehaviors>
<behavior name="BroadcasterServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<applicationSettings>
<MetricBroadcast.Properties.Settings>
<setting name="LogXML" serializeAs="String">
<value>True</value>
</setting>
</MetricBroadcast.Properties.Settings>
</applicationSettings>
</configuration>
好了,是时候脸红了-原来我编辑了错误的配置文件-它是为调试和发布环境设置的,我正在编辑核心文件,它在编译时被覆盖。
的Doh .
我会在角落里戴着尖顶帽子。
Rob