1 réponse
- Le plus récent
- Le plus de votes
- La plupart des commentaires
0
When connecting to Redis with cluster mode enabled, many clients will try to connect to all cluster nodes on initialization. The replica node(s) will not be reachable given the network setup that you have described. If you disable this behaviour of pre-connecting to all nodes, you should be able to successfully connect to the individual node that you have opened a tunnel onto.
Here is an example of how to connect without attempting to connect to all nodes, using the popular ioredis library:
let Redis = require('ioredis');
let cluster = new Redis.Cluster([{
host: 'localhost',
port: 6378
}], {
lazyConnect: true
});
async function main() {
await cluster.set("foo", "bar");
console.log(await cluster.get("foo"));
cluster.disconnect();
}
main();
NB: If more than one shard was setup in the cluster, this method would experience issues when hitting a shard on a different node to the node that you have tunnelled to.
répondu il y a un an
Contenus pertinents
- demandé il y a un an
- demandé il y a 2 mois
- demandé il y a un an
- AWS OFFICIELA mis à jour il y a un an
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 7 mois