websocket server cannot connect to redis
ive a websocket server and a redis server hosted on railway. after the migration, my ws server can no longer connect to my redis server. ive tried both the redis url and redis private url but i get the same error:
36 Replies
Project ID:
57346011-633f-4c77-851f-83e2a6f54bc0
57346011-633f-4c77-851f-83e2a6f54bc0
can you connect to the database with something like dbgate?
ive tried connecting from local host with the redis url and it works fine
okay thats good
have you updated the environment variables you use?
yes. i went into my ws server environment variables and added the redis url as a reference variable
${{Redis.REDIS_URL}}
show me the client code that connects to redis please
if i run the ws server locally with this exact code with the REDIS_URL set to the one found in railway redis variables, it works fine
and can i see your service variables?
do you just mean these?
the redis url was cut off at the bottom. heres a better ss
these are service variables from the redis service, please show me the variables on your apps service
what is the raw value of the redis url
isnt that sensitive? can i post it here?
if you're using a reference variable, its not sensitive
oh do you mean just ${{Redis.REDIS_URL}}?
is that what its set to?
yea when i edit it, thats what shows up. when i click the eye icon, the actual value shows up
then it leads me to believe you have incorrectly configured your client
it was all working before i was forced to migrate
how can i see if theres any misconfiguration
consult the documentation for the redis client in use
sorry not sure what u mean by this
Q: how can i see if theres any misconfiguration
A: consult the documentation for the the redis client you are using in your code
right but if i run that same code on localhost it works fine
the redis client connects fine to the instance
that does not mean there isnt a misconfiguration
this also happened directly after i was forced to migrate so im not sure it can be a misconfiguration of the redis client
^
if you console.log the REDIS_URL, does that match what you expect?
wondering if the migration messed up the env variable somehow
yes its the exact same url
i dont see any configuration issues that it could be. ive also tried updating to the latest version of the redis package and looked at the documentation and its the exact same way its been to connect to a redis instance as when i set it up
did you say you can use that url in your local env and it works?
exactly
this issue only started when i was forced to migrate my redis db on railway
I think Brody will know better 😅 but at least some reading I did here https://github.com/redis/node-redis/issues/2550 it seems like alot of people experienced some connection issues due to the Redis version. I’m not sure but maybe the package you’re using needs updating?
GitHub
ConnectionTimeoutError: Connection timeout · Issue #2550 · redis/no...
Description Code snippet for connecting the redis is below. this.client = redis.createClient({ socket: { host: redisHost, port: REDISPORT}, }); this.client.connect(); this.client.on("error&quo...
tried updating the package to latest it didnt work
also tried increasing the connection timeout limit from 5seconds to 15seconds
oh wait nvm i think increasing the connection timeout limit fixed it
nope. looks like disabling private network on my redis instance fixedi t
no idea why that would do it
Hmm, strange. Ideally you’d connect via your private network
turn private networking back on and then try adding a 3 second sleep to your start command