0

I'm using the Azure Dedicated cache to store my session state in and I've recently been getting connection failures which then take my application down. The only way to fix it is to restart the app.

Does anyone know of a way to catch this type of exception and then refresh the cache connection on the fly?

I am using azure caching library 2.3 and I following this article to setup the sessionstate in the cache. http://azure.microsoft.com/en-us/documentation/articles/cache-dotnet-how-to-use-service/#store-session

Here is the exception I am getting.

"ClassName": "Microsoft.ApplicationServer.Caching.DataCacheException", "Message": "There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable, which could be caused by busy network or servers. For on-premises cache clusters, also verify the following conditions. Ensure that security permission has been granted for this client account, and check that the AppFabric Caching Service is allowed through the firewall on all cache hosts. Also the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client.)", "Data": { "The client was trying to communicate with the server: net.tcp://xxxxx.cache.windows.net:23233.": null },

Thanks!

TWilly
  • 4,863
  • 3
  • 43
  • 73

1 Answers1

0

I was directed to this post which gives some details on how to refresh the Azure DataCacheFactory.

http://blogs.msdn.com/b/cie/archive/2014/04/29/cache-retry-fails-what-next.aspx

I'm only using the built in SessionProvider so I think this was a bit much and I couldn't understand everything that was going on. So instead I'm catching the exception and then restarting the role so that a new connection can be established on app startup.

Here is the root cause of problem from that post..

Reasons in general can be in case of High Availability the underlying cache service is load balancing the partitions and the secondary node is transitioning to primary and the client still is sending request to old primary node OR for some reason the cache service got moved to a different VM as part of service healing process but cache client still is having the old IP address of cache service VM.

Though its good to have a retry policy in place but in extreme cases where retry is not helping then you could use below approach in your application to mitigate the errors by refreshing the cache client when an exception is thrown.

TWilly
  • 4,863
  • 3
  • 43
  • 73