Client Config (client.ncconf)
This client configuration file (client.ncconf) is used by the NCache client API to get the initial information required to establish a connection with the server. This file is universal for all the client instances running on the client node. It is located at %NCHOME%\config in Windows or /opt/ncache/config in Linux. For modules that need to read the configurations, first try to find client.ncconf in the application folder. If client.ncconf is not found there, it then reads the configuration from the installation folder.
The client configuration file is used by the client to connect to the OutProc caches. Lightweight clients also use this configuration file to connect to remote caches. This file automatically updates each time a new cache/cluster is created. Similarly, it updates every time cache/cluster configuration settings are applied, as long as NCache is installed on the machine and the NCache service is running. Additionally, security information can be provided for each cache in this file.
Note
The same configurations can be specified via the CacheConnectionOptions API in Alachisoft.NCache.Client
. For more details on how to use the API while initializing caches, please refer to the Connect to Cache page in the Programmers' Guide.
Important
The configurations specified through CacheConnectionOptions
will override the configurations in the client.ncconf ONLY for the client that specifies them.
The client configuration file is explained below:
<configuration>
<ncache-server connection-retries="5" retry-connection-delay="0" retry-interval="1" command-retries="3" command-retry-interval="0.1" client-request-timeout="90" connection-timeout="5" port="9800" local-server-ip="20.200.20.38" enable-keep-alive="true" keep-alive-interval="30" />
<cache id="demoCache" client-cache-id="" client-cache-syncmode="optimistic" default-readthru-provider="" default-writethru-provider="" load-balance="True" enable-client-logs="False" log-level="error">
<server name="20.200.20.38"/>
<server name="20.200.20.23"/>
</cache>
</configuration>
client-request-timeout:
Client-request-timeout
is the period for which the client API waits for a response for a command from the server. After this period is lapsed an "OperationFailedException" is thrown. By default, this time period is 90 seconds and the minimum value is 60 seconds. If a time span is less than the minimum value it will automatically reset to the minimum value i.e. 60 seconds.
connection-retries:
connection-retries
are the number of retries the client makes on the whole list of servers mentioned in the client.ncconf file at the time when establishing a connection. It is the same if the connection breaks.
retry-interval: If the connection with the cache server is dropped, then the client tries to reconnect with the server and the retry connection delay flag introduces the delay between each retry. This flag is specified in seconds.
connection-timeout:
connection-timeout
is the time period threads wait before throwing OperationFailedException
during a connection-break, while one thread tries to establish a connection with the cache server. If the connection is successfully established, then all threads will complete their respective operations. Otherwise, they will throw an OperationFailedException
.
retry-connection-delay:
retry-connection-delay
is the time interval that the client API waits before going through another iteration of connection-retries. Delay is specified in seconds.
enable-keep-alive:
enable-keep-alive
specifies whether the connection between the client and server should be kept "alive", i.e., if the client is inactive (not communicating with its connected servers), it sends heart-beats or pings from the client to server nodes after fixed intervals according to the cache topology. This feature is particularly useful if there is a firewall that breaks idle network connections or if it detects connection breakages proactively.
keep-alive-interval:
keep-alive-interval
is the interval in seconds after which a heartbeat is sent from the idle client to the server to sustain the connection. The interval ranges between 1 and 7200 seconds with default set at 30 seconds. If any value is specified out of the range, NCache resorts to using the default value.
default-readthru-provider: Gets/Sets the ID of the default ReadThru Provider. If the provider is specified through API, this value will be overwritten with the value passed from API.
default-writethru-provider: Gets/Sets the ID of the default WriteThru Provider. If the provider is specified through API, this value will be overwritten with the value passed from API.
load-balance: When this flag is set, the client tries to connect to the optimum server in terms of the number of connected clients. This way an almost equal number of clients are connected to every node in the clustered cache and no single node is overburdened.
Port Forwarding Configuration
Note
If your cache servers and client applications are on the same subnet, you don't need to configure port forwarding.
If your cache servers and clients are on a different subnet or network, your client application might not be able to access your cache servers directly on the basis of IP addresses. In this case, you'll have to configure port forwarding and modify your client.ncconf file accordingly.
The following is a sample client.ncconf file with port forwarding configured:
<configuration>.
...
<server-end-point>
<end-point public-ip="172.19.0.11" public-ports="9801" private-ip="20.200.20.38" private-ports="9800"/>
<end-point public-ip="172.19.0.11" public-ports="1250-1260" private-ip="20.200.20.38" private-ports="8250-8260"/>
<end-point public-ip="172.19.0.11" public-ports="1300-1400" private-ip="20.200.20.38" private-ports="8300-8400"/>
<end-point public-ip="172.19.0.11" public-ports="9802" private-ip="20.200.20.23" private-ports="9800"/>
<end-point public-ip="172.19.0.11" public-ports="2250-2260" private-ip="20.200.20.23" private-ports="8250-8260"/>
<end-point public-ip="172.19.0.11" public-ports="2300-2400" private-ip="20.200.20.23" private-ports="8300-8400"/>
</server-end-point>
</configuration>
server-end-point: These represent the endpoints that will be used to communicate with the NCache servers.
end-point: The endpoint of the ncache server. A combination of an IP address and port.
public-ip: This is the IP address that is publicly accessible or present outside of the local network.
public-ports: The public ports that will be used to access the private ports.
private-ip: This is the IP address that is present within the local network and is not directly accessible. This is the IP address that is used by the NCache server.
private-ports: These are the ports that are not directly accessible. These are the ports used by the NCache server.
See Also
EFCaching Config
Server Side Configurations
Cache Server Settings
General Cache Settings