Connecter une application node.js à une instance Redis Scaleway
Publié le
Do not index
Do not index
Primary Keyword
Lié à Analyse sémantique (Articles liés) 1
Lié à Analyse sémantique (Articles liés)
Statut rédaction
Terminé
Lié à Analyse sémantique (Articles liés) 2
const Redis = require('ioredis');
const { readFileSync } = require('fs');
const { createAdapter } = require('@socket.io/redis-adapter');
const redisHost = "xx.xx.xx.xx" # Example : 192.168.0.13
const redisPort = 6379
const redisUser = "XXXXXXXXXXX"
const redisPassword = "XXXXXXXXXXX"
const redisConf = {
host: redisHost,
port: redisPort,
username: redisUser,
password: redisPassword,
connectionTimeout: 5000,
maxRetriesPerRequest: 3,
tls: {
ca: readFileSync("/opt/redis_certificate.pem"),
checkServerIdentity: (servername, cert) => {
// skip certificate hostname validation
return undefined;
},
}
}
const main = async () => {
console.log("Try to connect")
const pubClient = new Redis.Cluster([redisConf], {
redisOptions: {
password: redisPassword
},
scaleReads: 'all'
});
const subClient = pubClient.duplicate();
const adapter = createAdapter(pubClient, subClient);
//await pubClient.connect()
};
main()