Open HydraOrc opened 1 month ago
I just ran this script:
import { createClient } from 'redis';
await createClient({ host: '127.0.0.1', port: 6379 })
.on('error', err => console.error(err))
.on('connect', () => console.log('connected'))
.connect();
and this is what I'm getting:
Error: connect ECONNREFUSED 127.0.0.1:6379
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1602:16)
at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 6379
}
by default the client will try to reconnect forever, but you can change that using socket.reconnectStrategy
(see https://github.com/redis/node-redis/blob/master/docs/client-configuration.md#reconnect-strategy)
Description
I was debugging why my pub/sub system does not work and then realised that some ports might be closed. To verify that, I have passed totally random host and port to my connection, and it said CONNECTED!!! Expected behavious is that it should not allow you to "fake-connect" to any host and throw an error on timeout! .on('connect') callback IS called, and does not contain any error... .on('error') callback is not called AT ALL...
Node.js Version
18.20.2
Redis Server Version
6.0.16
Node Redis Version
4.6.10
Platform
Ubuntu
Logs
No response