You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the RedisPersistence class from the y-redis library to connect to a Redis server with custom host, port, and password. Despite providing the correct configuration, the connection defaults to localhost:6379.
Issue - passing variables directly to RedisPersistence:
require('dotenv').config();
const http = require('http');
const WebSocket = require('ws');
const setupWSConnection = require('y-websocket/bin/utils').setupWSConnection;
const RedisPersistence = require('y-redis').RedisPersistence;
// Redis Configuration without TLS
const redisConfig = {
host: REDIS_HOST,
port: REDIS_PORT,
password: REDIS_PASSWORD,
};
console.log('Redis Config:', redisConfig);
const redisPersistence = new RedisPersistence(redisConfig);
// Debug: Verify the RedisPersistence configuration
console.log('Redis Persistence:', redisPersistence);
// WebSocket Server Configuration
const port = 1234;
const server = http.createServer();
const wss = new WebSocket.Server({ server });
wss.on('connection', (ws, request) => {
const roomName = request.url.slice(1); // Remove leading "/"
setupWSConnection(ws, request, {
docName: roomName,
gc: false, // Disable garbage collection for persistence
persistence: redisPersistence, // Use Redis persistence
});
});
server.listen(port, () => {
console.log(`✅ y-websocket server running on http://localhost:${port} with Redis persistence enabled`);
});
Output of redis persistence showing config despite passing unique values to host, port and password it defaults to localhost:6379:
I am trying to use the RedisPersistence class from the y-redis library to connect to a Redis server with custom host, port, and password. Despite providing the correct configuration, the connection defaults to localhost:6379.
Issue - passing variables directly to RedisPersistence:
Output of redis persistence showing config despite passing unique values to host, port and password it defaults to localhost:6379:
Node.js version: Node.js v22.11.0
y-redis version: "^1.0.3"
Operating System: MacOS (Local Dev)
The text was updated successfully, but these errors were encountered: