• Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS
  • Docs
  • Comparisons
  • Blogs
  • Try NCache
  • Contact Us
Try NCache
Show / Hide Table of Contents

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. However, RESP is disabled by default. To allow Redis applications to connect, set enabled="true" for the cache in resp.ncconf. Once RESP is enabled and 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.

Note

After setting enabled="true" in resp.ncconf, restart the affected cache for the changes to take effect. For a clustered cache, update the configuration and restart the cache on each participating server node.

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,
    protocol=2,
    decode_responses=True
)

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();

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

Contact Us

PHONE

+1 214-619-2601   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Try NCache
Pricing
NCache Playground

Deployments
  • Cloud
  • Docker
  • Kubernetes
  • On-Premises
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • SignalR Backplane
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Blogs
  • Foundations
  • Videos
  • Comparisons
  • Shows
  • Whitepapers
  • Articles
  • Tech Talks
  • Magazine Articles
  • Third-Party Articles
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Docs
  • Schedule a Demo
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Terms of Use
  •  
  • Privacy Policy
  •  
  • Cookie Policy
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
  • Facebook
  • Twitter
  • Youtube
  • LinkedIn
  • RSS