Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection Drops with rediss:// URLs #1889

Closed
ilshm opened this issue Apr 28, 2024 · 2 comments
Closed

Connection Drops with rediss:// URLs #1889

ilshm opened this issue Apr 28, 2024 · 2 comments

Comments

@ilshm
Copy link

ilshm commented Apr 28, 2024

When using rediss:// URLs to connect to Redis instances hosted on DigitalOcean and Aiven servers in my Node.js application with the ioredis client library, I'm experiencing connection drops. However, when using RedisLabs servers with redis:// URLs (as they don't seem to support rediss://), the connection works fine.

After a period of server inactivity (approximately 5-10 minutes), I observe the following logs:

Redis connection closed
Connected to Redis
Redis connection closed
Connected to Redis

Environment:

ioredis version: 5.4.1
Node.js version: v20.12.1
Operating System: Ubuntu 22.04 (Digital Ocean Droplet: 8 GB Memory / 4 AMD vCPUs / 160 GB Disk / FRA1)

Steps to Reproduce:

const Redis = require('ioredis')

const redis = new Redis(process.env.REDIS_URL)

redis.on('connect', () => {
    console.log('Connected to Redis')
})

redis.on('close', () => {
    console.log('Redis connection closed')
})

redis.on('error', (err) => {
    console.error('Redis connection error:', err)
})

module.exports = redis
@eazylaykzy
Copy link

@ilyabumblebee that's a normal thing with most of the cloud hosted Redis offering, it disconnect after 300ms, you can get around that by implementing a ping to your Redis at intervals, probably ping it in your /healthcheck route.

@ilshm
Copy link
Author

ilshm commented Apr 30, 2024

Thanks, that's actually not too annoying. I was just curious about why that happens.

@ilshm ilshm closed this as completed Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants