redis / node-redis

Redis Node.js client
https://redis.js.org/
MIT License
16.89k stars 1.88k forks source link

client.connect() struck for the easiest sample #2842

Open syheliel opened 1 week ago

syheliel commented 1 week ago

Description

The following code is from README.md, I run it by node main.js

import { createClient } from 'redis';

const client = createClient();

client.on('error', err => console.log('Redis Client Error', err));

await client.connect();

And I start redis by

docker run -p 6379:6379 -it redis/redis-stack-server:latest

I can confirm that I can connect the server using redis-cli, But I can't do it in nodejs. Do I miss some essential operation to make it run?

Node.js Version

20.16.0

Redis Server Version

latest

Node Redis Version

4.7.0

Platform

Linux

Logs

No response

sjpotter commented 3 days ago

i don't see anything obviusly wrong, and the basic structure works for me, something else must be going on.

syheliel commented 2 days ago

I can reproduce the error on my other machine. Do you have some idea to get further information for debugging?

sjpotter commented 2 days ago

does it just hang? for instance, if I try to do it without a redis-server running on localhost:6379, I get a repeated error of

Redis Client Error Error: connect ECONNREFUSED 127.0.0.1:6379

which makes sense.

to not get that error, would imply that its "connecting", but stuck somewhere, which makes little sense to me.