WCF服务中的中止错误消息

时间:2015-09-04 17:03:59

标签: c# wcf

我有一个托管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.

我的尺寸全部超出以及超时,客户端没有下降。有关原因的任何建议吗?

罗布

如同要求,这是配置文件:

客户端

<?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=&quot;data source=MARSH\SQL2012;initial catalog=Aria;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" 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=&quot;data source=BIC-SVR-AMS1;initial catalog=ToroRossoAMS;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" 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>

1 个答案:

答案 0 :(得分:0)

好吧,它的时间有点红了 - 事实证明我正在编辑错误的配置文件 - 它已经设置用于调试和发布环境,而我正在编辑核心版本,在编译时会被覆盖。

卫生署。

我会戴着尖尖的帽子在角落里。

罗布