Search code examples
c#.netwcfload-balancingkeep-alive

maintaining user session on WCF Clients while making calls to servers behind a load balance


My problem is the following: - I have a .Net MVC site making a lot of calls to WCF services hosted in two server behind a load balancing server (BIGip).

I do have to maintain a user session on the WCF services (controlled by a custom token). My problem is that the sticky session is not working when a lot of users is logged on the site (a lot of concurrent calls to the services).

What I figured out was that when the site calls the service reusing a existing connection, the load balancing server ignores the sticky session cookie and forwards the request to the last server that received a call by this connection.

I checked using sniffer (Wireshark), and every call is sent to the load balancing server with the correct sticky session token.

When a connection is created from scratch the stick session cookie is taken into account and the request goes to the right server.

So, how can I handle that situation? I'm looking for something that enforces creating a new connection on each call, but the property KeepAliveEnabled="false" is not working.

Tks.


Solution

  • My problem was solve using the correct keepAliveConnection configuration to Framework 4. Bellow are the configs.

    The wrong one

    <bindings>
      <customBinding>
        <binding name="WSHttpBinding_IServiceSessionCreator" keepAliveEnabled="false">
          <httpTransport />
        </binding>
      </customBinding>
    </bindings>
    

    The correct one

    <bindings>
      <customBinding>
        <binding name="WSHttpBinding_IServiceSessionCreator" >
          <textMessageEncoding />
          <httpTransport allowCookies="false" keepAliveEnabled="false"/>
        </binding>
      </customBinding>
    </bindings>
    

    I don't know why the first one did not work. I saw it in this link http://msdn.microsoft.com/en-us/library/vstudio/ms730128(v=vs.100).aspx