2

I'm using a duplex ReliableSecureProfile in WCF and the server will stop listening to new requests if an exception occurs on any client.

How can I make the server more resilient to failures that happen to any single client? Everything works again if I restart the server or redeploy

My client code looks like this:

            CustomBinding rspBinding = new CustomBinding();
            rspBinding.Elements.Add(new ReliableSessionBindingElement());
            rspBinding.Elements.Add(new MakeConnectionBindingElement());
            rspBinding.Elements.Add(new TextMessageEncodingBindingElement());
            rspBinding.Elements.Add(new HttpTransportBindingElement());

            DuplexChannelFactory<IProcessDataDuplex> channelFactory =
                new DuplexChannelFactory<IProcessDataDuplex>
                    (new CallbackHandler(), rspBinding, serviceAddress);

            //
            // The problem always occurs on this line.
            //
            reusableSW = new LC.Utils.WCF.ServiceWrapper<IProcessDataDuplex>(channelFactory);

My web.config looks like this:

   <system.serviceModel>

    <behaviors>
      <serviceBehaviors>
        <behavior name="rspServiceBehavior">
          <serviceMetadata httpGetEnabled="true" policyVersion="Policy15" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"  />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <useRequestHeadersForMetadataAddress>
            <defaultPorts>
              <add scheme="http" port="80" />
              <add scheme="https" port="443" />
            </defaultPorts>
          </useRequestHeadersForMetadataAddress>
        </behavior>
      </serviceBehaviors>



    </behaviors>
    <bindings>
      <customBinding>
        <!-- Reliable Secure Profile -->
        <binding name="rspBinding">
          <reliableSession />
          <MakeConnectionBindingElement/>
          <textMessageEncoding />
          <httpTransport />
        </binding>
      </customBinding>

      <netTcpBinding>
        <binding portSharingEnabled="true" >
          <security mode="None" />
        </binding>
      </netTcpBinding>

    </bindings>

    <extensions>
      <bindingElementExtensions>

        <!-- Reliable Secure Profile -->
        <add name="MakeConnectionBindingElement" type="Microsoft.Samples.ReliableSecureProfile.MakeConnectionElement, Microsoft.Samples.ReliableSecureProfile.MakeConnectionChannel" />

      </bindingElementExtensions>
    </extensions>

    <services>


      <!-- Reliable Secure Profile -->
      <service behaviorConfiguration="rspServiceBehavior" name="Microsoft.Samples.ReliableSecureProfile.RSPService">
        <endpoint binding="customBinding" bindingConfiguration="rspBinding"
            contract="Microsoft.Samples.ReliableSecureProfile.IProcessDataDuplex"
            listenUriMode="Explicit">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
            contract="IMetadataExchange" />
        <host>
        </host>
      </service>

      <!--<service name="WcfTcpTest.Service1" >
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:1337/Service1/" />
          </baseAddresses>
        </host>
        <endpoint address="" binding="netTcpBinding" contract="WcfTcpTest.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"/>
      </service>-->

    </services>
    <protocolMapping>
      <clear/>
      <!-- removes all defaults which you may or may not want. -->
      <!-- If not, use <remove scheme="http" /> -->
      <add scheme="http" binding="customBinding" bindingConfiguration="rspBinding"/>
    </protocolMapping>
    <serviceHostingEnvironment
      aspNetCompatibilityEnabled="false"

      multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
makerofthings7
  • 60,103
  • 53
  • 215
  • 448
  • What does your client do with the channel after the exception has been thrown? Does it clean up properly? – razlebe May 31 '11 at 00:38
  • @razlebe - no it doesn't clean up properly. I'm trying to account for that server-side as well. This is intended to be a public service subject to abuse – makerofthings7 May 31 '11 at 00:45
  • Related: I'm trying to debug my service and am getting hung up on VS2010 with SP1's weird behavior: [Unhandled Exception in VS2010 debugger even though the exception is actually being caught](http://stackoverflow.com/questions/5623456/getting-an-unhandled-exception-in-vs2010-debugger-even-though-the-exception-is-ha) – makerofthings7 May 31 '11 at 00:49
  • Related: I intend to incorporate the resolution of this issue into this FOSS code [How to handle WCF exceptions (consolidated list with code)](http://stackoverflow.com/questions/6130331/how-to-handle-wcf-exceptions-consolidated-list-with-code) – makerofthings7 May 31 '11 at 00:58

1 Answers1

0

I can't reproduce this issue anymore (where the server simply stops responding). I think the issue is related to VS2010's desire to catch handled exceptions and stop all threads as explained here:

Getting an Unhandled Exception in VS2010 debugger even though the exception IS handled

Community
  • 1
  • 1
makerofthings7
  • 60,103
  • 53
  • 215
  • 448