14 days ago
Hi, i have a persistent problem with redis:
Logs:
Reconnecting to Redis in 1000ms
Redis Error: Error: read ECONNRESET
at TLSWrap.onStreamRead (node:internal/stream_base_commons:218:20) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read'
}
Reconnecting to Redis in 1000ms
Redis Error: Error: Client network socket disconnected before secure TLS connection was established
at TLSSocket.onConnectEnd (node:_tls_wrap:1730:19)
at TLSSocket.emit (node:events:536:35)
at endReadableNT (node:internal/streams/readable:1698:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ECONNRESET',
path: undefined,
host: 'switchback.proxy.rlwy.net',
port: 49250,
localAddress: undefined
}
// src\redis\client.ts
import Redis from 'ioredis'
import { env } from '../env'
export const redis = new Redis(env.REDIS_URL, {
tls: {
rejectUnauthorized: false,
},
connectTimeout: 15000,
retryStrategy: times => Math.min(times * 30, 1000),
})
redis.on('command', command => {
console.log('Redis Command:', command)
})
redis.on('error', err => {
console.error('Redis Error:', err)
})
redis.on('connect', () => {
console.log('Connected to Redis!')
})
redis.on('reconnecting', (delay: number) => {
console.log(`Reconnecting to Redis in ${delay}ms`)
})
// ENV
REDIS_URL="rediss://default:PASSWORD@switchback.proxy.rlwy.net:49250"
Repository: https://github.com/AleferReinert/devstage-api
2 Replies
14 days ago
Hey there! We've found the following might help you get unblocked faster:
🧵 Client network socket disconnected before secure TLS connection was established
🧵 Private Network Connectivity Issue: Node.js Worker to Redis (Southeast Asia)
If you find the answer from one of these, please let us know by solving the thread!
14 days ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open brody • 14 days ago
13 days ago
This error usuall occurs when you are trying to connect to Redis over TLS from a Railway service that’s on the same project but internal Redis URLs don’t support TLS.
So a suggested fix will be to remove the tls
option entirely when connecting to the internal Railway Redis.
export const redis = new Redis(env.REDIS_URL, {
// remove the tls block
// tls: {
// rejectUnauthorized: false,
// },
connectTimeout: 15000,
retryStrategy: times => Math.min(times * 30, 1000),
})
but if you are connecting externally(not from railway) then you do need TLS and in that case, double-check your environment credentials (like password, Redis URL, and port) to make sure they’re correct.