Connect Redis Clients to RESP Protocol Server in Windows
When a cache is created through NCache Management Center or the New-Cache PowerShell cmdlet, NCache automatically adds its RESP listener configuration to resp.ncconf and assigns an available port from the reserved range 9981–9989. Once the cache is running, Redis applications can access NCache through the server address and the port assigned to that cache. Existing Redis client libraries can be used by updating their connection settings, without replacing the application's Redis API calls.
The following examples use a two-node Partition-Replica cache with CRC16 routing enabled on both servers: 20.200.20.11:9981 and 20.200.20.12:9981. Verify the assigned ports in resp.ncconf and use your server endpoints when configuring Redis clients.
Note
For the best RESP performance and scalability, configure your Redis clients to use the CRC-Compliant Cluster connection model. This allows clients to route key-based operations directly to the appropriate NCache server and provides alternatives for reconnecting when a node becomes unavailable.
Redis CLI
The Redis command-line interface (redis-cli) can verify connectivity to both NCache RESP endpoints. Use the -c option to enable Redis Cluster redirection support when CRC16 routing is configured. Run the following commands separately to connect to each server:
redis-cli -c -h 20.200.20.11 -p 9981
redis-cli -c -h 20.200.20.12 -p 9981
At either interactive prompt, run PING to verify that the listener responds with PONG. Each redis-cli invocation starts with one endpoint and can follow Redis Cluster redirects; the two commands above verify the two server endpoints independently.
.NET
.NET applications can use StackExchange.Redis with both RESP endpoints. When CRC16 cluster routing is enabled, the connection multiplexer discovers the cluster layout and directs key-based requests to the appropriate server. Configure authentication and TLS separately if required.
using StackExchange.Redis;
var options = new ConfigurationOptions();
options.EndPoints.Add("20.200.20.11", 9981);
options.EndPoints.Add("20.200.20.12", 9981);
// Connect using both cluster endpoints.
var redis = await ConnectionMultiplexer.ConnectAsync(options);
Java
Java applications using Jedis can connect to the CRC-Compliant Cluster through a cluster-aware client. Supply both NCache RESP endpoints as startup nodes so the client can discover the Redis hash-slot map and route requests directly to the responsible node.
import java.util.HashSet;
import java.util.Set;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
Set<HostAndPort> nodes = new HashSet<>();
nodes.add(new HostAndPort("20.200.20.11", 9981));
nodes.add(new HostAndPort("20.200.20.12", 9981));
// Create the cluster-aware client using both startup nodes.
JedisCluster cluster = new JedisCluster(nodes);
Python
Python applications using redis-py can use RedisCluster for CRC16 routing. Specify both startup nodes through ClusterNode so the client can discover the cluster and establish connections to the correct NCache servers.
from redis.cluster import ClusterNode, RedisCluster
startup_nodes = [
ClusterNode("20.200.20.11", 9981),
ClusterNode("20.200.20.12", 9981),
]
client = RedisCluster(startup_nodes=startup_nodes)
Node.js
Node.js applications using the redis package can use createCluster with the two NCache RESP endpoints. The cluster client retrieves the slot map and routes supported key-based commands directly to the relevant node.
import { createCluster } from 'redis';
const cluster = createCluster({
rootNodes: [
{ url: 'redis://20.200.20.11:9981' },
{ url: 'redis://20.200.20.12:9981' }
]
});
// Establish a cluster connection.
await cluster.connect();
Redis Cluster and Multiple Endpoints
The examples above use CRC-Compliant Cluster, which is recommended for Partitioned and Partition-Replica caches. With CRC16 routing enabled, Redis Cluster-aware clients discover key ownership and send requests directly to the responsible NCache server. For successful connectivity, ensure the following:
- CRC16 routing is enabled on the NCache RESP listeners.
- Both configured startup endpoints are reachable from the client.
- All server addresses advertised during cluster discovery are accessible to the client.
Alternatively, applications can use One Endpoint or Multiple Endpoints without CRC16 routing. However, these connection models have the following limitations:
- Server-side forwarding: Requests for remotely owned keys require additional server-to-server communication, reducing performance compared to CRC-Compliant Cluster.
- Failover: Multiple Endpoints can provide connection failover if supported by the Redis client library, whereas One Endpoint depends on a single configured server.
- No direct key routing: Configuring multiple endpoints does not automatically enable CRC16 routing or allow the client to identify the server responsible for each key.
For listener and port configuration, see Install and Configure NCache RESP Server. This page explains the RESP listener settings and port allocation for the configured cache.
See Also
Install and Configure NCache RESP Server
NCache RESP Server Architecture
NCache RESP Server Security