3

When using a WSHttpBinding in WCF with reliableSessions enabled, my service reference updates itself to:

<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true">
</reliableSession>

I cannot add the maxRetryCount attribute to the reliableSession as long as the binding is configured as a WSHttpBinding.

Now my question: what is the value of maxRetryCount when using a WSHttpBinding, and is there any way to change this in config; without the use of a CustomBinding?

Jan Jongboom
  • 26,598
  • 9
  • 83
  • 120
  • 1
    The default value for maxRetryCount on a wsHttpBinding is 8 - but it's only active, if the reliable session is enabled, of course. That's the number of messages that can be buffered on the client and the server - multiply that by the max message size you allow, and you get an idea of how big the "reliability" buffer is going to be. You don't want to make that too big. – marc_s Dec 28 '09 at 11:23
  • And as far a I know, there is no other way than using a custom binding (configured in your app.config/web.config, or through code) to set that value to something else other than 8. – marc_s Dec 28 '09 at 11:23

1 Answers1

8

You cannot set the maxRetryCount on a standard wsHttpBinding configuration. In order to set that value, you need to create a separate custom binding and then reference that from your service or client config:

  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="wsCustomBinding">
          <reliableSession maxRetryCount="15"/>
          <textMessageEncoding/>
          <httpTransport />
        </binding>
      </customBinding>
    </bindings>
    <services>
      <service name="MyService">
        <endpoint address="http://localhost:7878/MyServoce"
                  binding="customBinding"
                  bindingConfiguration="wsCustomBinding"
                  contract="IMyService" />
      </service>
    </services>
  </system.serviceModel>

Defining a custom binding isn't hard - but you need to make sure you specify the elements that make up the binding in the right order - see the MSDN docs on custom bindings for a reference.

If you want to share the custom binding configuration between server and client, you could also put that <bindings> section into a separate bindings.config file, and then reference that external file from your web.config/app.config:

  <system.serviceModel>
    <bindings configSource="bindings.config">

Visual Studio will complain about this and show red squiggly underlines - but trust me - the technique works, I use it in production every day (the Visual Studio XML schema describing the config stuff isn't complete and accurate).

Marc

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Yeah I was aware of the customBinding workaround. Have you got any clue what the retry count value is on a wsHttpBinding, or is retry disabled for ws bindings? – Jan Jongboom Dec 28 '09 at 11:19
  • @marc_s what will cause to retry ? timeout ? server exception ? hardware error ? ( on the target service...) – Royi Namir Nov 03 '12 at 05:14