Redis connection closed on private network
Hi, I'm facing the following issue with redis.
I have a nestjs application where I'm using redis as the transport layer between microservices.
When I set the
PUB_SUB_URL
to ${{pubsub.REDIS_URL}}
which is the public url everything is fine.
But if I change the variable to ${{pubsub.REDIS_PRIVATE_URL}}
I a connection closed error.
I've read about the private network initialisation times on railway but the redis service is already up and running at the time of deploying my nestjs app
projectId: 8a8bfe2d-1094-4b5f-834a-eba6388d0180Solution:Jump to solution
put the sleep back to 3 seconds, and set
family
to 0
in the options for that transport12 Replies
Project ID:
8a8bfe2d-1094-4b5f-834a-eba6388d0180
I've read about the private network initialisation times on railway but the redis service is already up and running at the time of deploying my nestjs appthis applies to your app itself, please try adding a 3 second sleep to your start script
I've tried to do it within my app but no luck
are you deplying with a dockerfile?
No
I could try if that's a possible fix
try increasing the sleep time
what package does the redis transport use? ioredis?
Yes, [email protected] judging by the logs. Will try 20sec for testing
Solution
put the sleep back to 3 seconds, and set
family
to 0
in the options for that transportIt looks like nestjs doesn't allow to set the family when defining the transport... I also have another service which is using redis through ioredis and setting the family allowed for using the private url which is great.
Is there any other way to make this work without the family?
Have you try setting it anyway in the options object? the interface doesn't contain
family
https://github.com/nestjs/nest/blob/master/packages/microservices/client/client-proxy.ts but the options are passed down to the redis client anyway https://github.com/nestjs/nest/blob/master/packages/microservices/client/client-redis.ts#L76Tried earlier and got an error but will try again as I was trying all sorts of things at the time
Ok, that actually did it! Must've been something unrelated earlier.
Thanks a lot!
I'm glad it worked because that's exactly what I said to do 😆