Windows Azure Caching 2.1.0.0: “No such host is known”

 

Few days ago(on 31st July), the Azure Caching libraries were updated to v2.1.0.0 (previous version was v2.0.0.0).

If you are trying to use Windows Azure Caching on your new project from past few days, and if it is mysteriously not working, not even for the simplest of the projects, then you may be running into a dependency scenario!

A lot of us may have probably missed that this new version of Azure Caching has a dependency on Azure SDK v 2.1

See the highlighted part (easy to miss if we are in a hurry Smile).

image

 

 

So what would happen if we try to use Azure Caching 2.1.0.0 with Azure SDK 2.0 or older?

 

You may run into following issues

1. Your project may appear to hang for a while (browser spinning etc.).

2. Eventually you may see errors like

Exception Details: System.Net.Sockets.SocketException: No such host is known

DataCacheException: ErrorCode<ERRCA0017>:SubStatus<ES0006>

Detailed exception:

 Server Error in '/' Application.
 
No such host is known 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
 
Exception Details: System.Net.Sockets.SocketException: No such host is known
 
Source Error: 
 
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 
Stack Trace: 
 
 

[SocketException (0x2af9): No such host is known]
   Microsoft.ApplicationServer.Caching.AsyncResultNoResult.EndInvoke() +202
   Microsoft.ApplicationServer.Caching.AsyncResult`1.EndInvoke() +40
   Microsoft.ApplicationServer.Caching.SocketConnectionFactory.EndConnect(IAsyncResult asyncResult) +75
   Microsoft.ApplicationServer.Caching.TcpClientChannelFactory.TcpConnectionCallback(IAsyncResult result) +182
[DataCacheException: ErrorCode<ERRCA0017>:SubStatus<ES0006>: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.). Additional Information : The client was trying to communicate with the server: net.tcp://WebRole1:24233.]
   Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus, Guid trackingId, Exception responseException, Byte[][] payload, EndpointID destination) +767
   Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, EndpointID destination) +149
   Microsoft.ApplicationServer.Caching.DataCacheFactory.EstablishConnection(IEnumerable`1 servers, RequestBody request, Func`3 sendMessageDelegate, DataCacheReadyRetryPolicy retryPolicy) +1313
   Microsoft.ApplicationServer.Caching.<>c__DisplayClass5.<Initialize>b__2(RequestBody req) +198
   Microsoft.ApplicationServer.Caching.SocketClientProtocol.SendReceive(IVelocityRequestPacket request, Func`2 delegate, EndpointID& destination) +121
   Microsoft.ApplicationServer.Caching.SocketClientProtocol.Initialize(IEnumerable`1 servers) +1225
   Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate, DataCacheInitializationViaCopyDelegate initializeDelegate) +1104
   Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +131
   Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName) +63
   Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler`1 fetchingHandler, EventHandler`1 fetchedHandler) +356
   Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateInternalProvider(IHttpRuntime httpRuntime, SessionInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +447
   Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetInternalProvider() +315
   Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateNewStoreData(HttpContext context, Int32 timeout) +59
   System.Web.SessionState.SessionStateModule.InitStateStoreItem(Boolean addToContext) +160
   System.Web.SessionState.SessionStateModule.CompleteAcquireState() +363
   System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +1269
   System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +12598974
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18033 

Please note that only including the new package in your solution will NOT cause these issues. These symptoms will appear only when you are actually trying to ‘use’ caching features. Like, enabling the Azure Caching Session State provide, or instantiating the DataCache objects etc..

Okay, we know there is a dependency. But what do we do now?

Here are two easy options

1. Upgrade your Azure SDK to the latest version (v2.1) (this should be the right and recommended way)

Download Latest Azure SDK

2. If for some reason, you can not upgrade your Azure SDK at the moment, then you can manually install previous version of Azure Caching. (of course you will be missing on the new things v2.10.0 has to offer)

a. Go to Visual Studio –> Open your project where you want to install Azure Caching libraries 

b. Tools –> Library Package Manager –> Package Manager Console

c. This should bring up ‘Package Manager Console’ window

d. Run following command in that console window

>Install-Package Microsoft.WindowsAzure.Caching -Version 2.0.0.0

This should install the v2.0.0.0 of Azure Caching which you can use with your older versions of Azure SDK (<v2.1)

 

 

Hope this help!