none
WCF Communication Exception. RRS feed

  • Question

  • Hi,

    We are using WCF service in our application, whose main responsibility is to upload .bin files to azure blobs and updating sql azure database.

    The reliable session has been enabled with no security set for the service with receiveTimeout and InactivityTimeout set to 1 hour.

    following is the web.config on the service side:
    <system.web>
        <httpRuntime maxRequestLength="65536000"/>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelMessageLoggingListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
          <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelTraceListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
          <add initializeData="e:\techpolicy\src\prod\import\upload\service\web_messages.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
            <filter type="" />
          </add>
          <add initializeData="e:\techpolicy\src\prod\import\upload\service\web_tracelog.svclog"
            type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
            <filter type="" />
          </add>
        </sharedListeners>
        <trace>
          <listeners>
            <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
              name="AzureDiagnostics">
              <filter type="" />
            </add>
          </listeners>
        </trace>
      </system.diagnostics>
      <system.serviceModel>
        <diagnostics>
          <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
          <endToEndTracing activityTracing="true" />
        </diagnostics>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
        <bindings>
          <wsHttpBinding>
            <binding name="wsHttpUploadServiceBinding" maxReceivedMessageSize="65536000" receiveTimeout="01:00:00">
              <security mode="None" />
              <reliableSession enabled="true" inactivityTimeout="01:00:00" ordered="false"/>
              <readerQuotas maxDepth="32" maxStringContentLength="81920000" maxArrayLength="3276800"
                maxBytesPerRead="4096" maxNameTableCharCount="3276800" />
            </binding>
          </wsHttpBinding>
          <!--<customBinding>
            <binding name="wsHttpUploadServiceBinding">
              <transactionFlow/>          
              <reliableSession ordered="false" flowControlEnabled="true" maxPendingChannels="128" inactivityTimeout="01:00:00" />
              <textMessageEncoding>
                <readerQuotas maxDepth="32" maxStringContentLength="81920000" maxArrayLength="3276800"
                  maxBytesPerRead="4096" maxNameTableCharCount="3276800"/>
              </textMessageEncoding>
              <httpTransport maxBufferSize="65536000" maxReceivedMessageSize="65536000"  />
            </binding>
          </customBinding>-->
        </bindings>
        <services>
          <service behaviorConfiguration="UploadServiceBehavior" name="Microsoft.Spectrum.Import.Upload.Service.UploadService">
            <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpUploadServiceBinding"
              contract="Microsoft.Spectrum.Import.Upload.Contract.IUploadService" />
          </service>
        </services>

        <behaviors>
          <serviceBehaviors>
            <behavior name="UploadServiceBehavior">
              <serviceThrottling maxConcurrentSessions="60"/>
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="204800000" />
          </requestFiltering>
        </security>
      </system.webServer>

    On the client side configuration looks like:

        WSHttpBinding binding = new WSHttpBinding(SecurityMode.None, true);
                binding.CloseTimeout = TimeSpan.FromMinutes(1.0);
                binding.OpenTimeout = TimeSpan.FromMinutes(10.0);
                binding.ReceiveTimeout = TimeSpan.FromHours(1);
                binding.SendTimeout = TimeSpan.FromHours(1);            
                binding.MaxBufferPoolSize = 524288;
                binding.MaxReceivedMessageSize = 65536000;
                binding.UseDefaultWebProxy = true;
                binding.ReaderQuotas = new XmlDictionaryReaderQuotas();
                binding.ReaderQuotas.MaxDepth = 32;
                binding.ReaderQuotas.MaxStringContentLength = 81920000;
                binding.ReaderQuotas.MaxArrayLength = 3276800;
                binding.ReaderQuotas.MaxBytesPerRead = 4096;
                binding.ReaderQuotas.MaxNameTableCharCount = 3276800;
                binding.ReliableSession.Enabled = true;
                binding.ReliableSession.Ordered = false;
                binding.ReliableSession.InactivityTimeout = TimeSpan.FromHours(1);            
                
                EndpointAddress endpointAddress = new EndpointAddress(serviceUri);            

                //CustomBinding customBindig = new CustomBinding(binding);

                return new ChannelFactory<IUploadServiceChannel>(binding, endpointAddress);                                                                 

    Our client code is written such a way that it will create a channel for each file to be uploaded [ Approx file size would 50MB]. The channel creation happens  in parallel (multi-threading).                                                                                         
            Now the problem is that the  communication exception is getting thrown when the service operation being called for the 10th request [i.e for 10th file channel request]. The exception is getting thrown exactly at the 10th client request. Not sure what threshold it is getting crossed.  The number of files attempted upload here is 21.                                                                                                                                                                                                                                                        As per service throttling values, the load which I am trying process will not get surpass, because the machine what I am using is dual core and WCF service version is 4.0. The instanceContext is not been set, which means by default  it is using per session call.                                                                                                                                                                                                                                                                                                                                                                           But, the strange thing noticed is same service will work file when we run the client on high end machine having RAM size 32GB, I don't know how much it matters here. Number of files being uploaded is 51.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 The exception details are follows:                                                                                                                                           

    Error occurred while uploading the file D:\Errors\EBC-SO_130618_110419.bin 
     Exception Details: System.ServiceModel.CommunicationException: The remote endpoint no longer recognizes this sequence. This is most likely due to an abort on the remote endpoint. The value of wsrm:Identifier is not a known Sequence identifier. The reliable session was faulted.
    Server stack trace:
       at System.ServiceModel.Channels.InterruptibleWaitObject.Wait(TimeSpan timeout, Boolean throwTimeoutException)
       at System.ServiceModel.Channels.ReliableOutputConnection.Close(TimeSpan timeout)
       at System.ServiceModel.Channels.ReliableRequestSessionChannel.OnClose(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnClose(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
       at System.ServiceModel.Dispatcher.TerminatingOperationBehavior.AfterReply(ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Microsoft.Spectrum.Import.Upload.Contract.IUploadService.WriteMeasurementFooter()
       at Microsoft.Spectrum.Import.JobFileWorker.Run(String correlationId, PauseToken pauseToken, ProgressToken progressToken, JobFileWorkerRunPayload runPayload) in c:\SOAMainTFS\Main\src\prod\Import\JobFileWorker.cs:line 99
       at Microsoft.Spectrum.Import.WorkerBase`4.OnRunRequest(WorkerMessage`1 runMessage) in c:\SOAMainTFS\Main\src\prod\Import\WorkerBase.cs:line 247 


    Tried setting maxPendingChannels property in custom binding,but didn't work, no idea what is going wrong with the code.                                                                                                                                                                                                    Please let me know any possible solution for the above problem.

     Thanks in advance for the help.                                                                                                                                                                                                                                                                                                                                                   Thanks,                                                                                                                                                                                     Madhu


    Madhusudhan GS

    Friday, July 5, 2013 4:35 AM

All replies