Connecting to local nCache

2.3k Views Asked by At

I'm trying to setup my local nCache development. In my ASP.net code, I'm calling the following:

Cache cache = NCache.InitializeCache("local-test");

However, it is throwing an OperationFailedException:

No server is available to process the request for local-test

Any idea why? The documentation says that this error typically relates to firewall issues, but I'm running this thing locally.

Configuration

In %NCHOME%\config\client.ncconf, the cache is identified:

<cache id="local-test" client-cache-id="" client-cache-syncmode="optimistic" default-readthru-provider="" default-writethru-provider="" load-balance="True"> <server name="My IP address"/> </cache>

...and config.ncconf has the following definition:

<cache-config name="local-test" inproc="False" config-id="0" last-modified="" type="local-cache" auto-start="False"> <log enabled="True" trace-errors="True" trace-notices="False" trace-warnings="False" trace-debug="False"/> <perf-counters enabled="True"/> <compression enabled="False" threshold="100kb"/> <notifications item-remove="False" item-add="False" item-update="False" cache-clear="False"/> <cleanup interval="15sec"/> <storage type="heap" cache-size="250mb"/> <eviction-policy enabled="True" default-priority="normal" policy="lru" eviction-ratio="5%"/> </cache-config>

2

There are 2 best solutions below

0
On

I am listing down some the reasons for this exception to be raised. • This error is sometimes thrown when the Cache you are trying to connect is stopped on the machine

You can verify this by running the 'Get-Caches' cmdlet from PowerShell. If it is not currently running on this machine, you can start the Cache by using the 'Start-Cache' cmdlet from PowerShell.

PowerShell Guide: http://www.alachisoft.com/resources/docs/ncache/powershell-ref/

• When an application tries to connect to the Cache, the IPs where the Cache is hosted are checked through the Client.ncconf file ("C:\Program Files\NCache\config\client.ncconf"). If the IPs that are mentioned are wrong, your call may go to a completely different server where either cache is not running or service is not accessible at all.

You can review that the IP configured against the Cache in the Client.ncconf is the same as what you have currently running on the box. So for example if your IP is '192.16.1.1' then your Cache's client.ncconf tag should look something like this.

<cache id="mycache" client-cache-id="" client-cache-syncmode="optimistic" default-readthru-provider="" default-writethru-provider="" load-balance="False" enable-client-logs="False" log-level="error">
<server name="192.16.1.1"/></cache> 

This IP should be the same as the one that is configured in the NCache Service configuration file. • If the machine has dual IPs and the NCache Service is running on a different IP (than the one where the Cache is hosted or configured to host) then your application may also get this error.

Please make sure that your NCache Service is currently running on the correct IP as well. Please check the value against the following tags in the NCache Service Configuration file (C:\Program Files\NCache\bin\service\Alachisoft.NCache.Service.exe.config)

<add key="NCacheServer.BindToClusterIP" value=" xx.xx.xx.xx "/>
<add key="NCacheServer.BindToClientServerIP" value="xx.xx.xx.xx"/>

Please make sure that this is the same IP as the one configured in the Client.ncconf file. • This error could also be thrown in such a scenario where there is a firewall enabled on the machine, it could be denying the access to the ports on which the Cache host process is running. .

Please make sure that the Cache Ports are opened in the Firewall, if the firewall is enabled. You can verify the Cache's Port from this file "C:\Program Files\NCache\bin\service\CacheHostPorts.xml". If this still doesn't work, please disable the firewall completely and check.

0
On

I had an old version of the NCache libraries installed. When I upgraded the client DLLs, everything started working.