When I try to connect to Redis service I get an error as :
ReplyError: ERR invalid DB index
at parseError (/app/node_modules/redis-parser/lib/parser.js:179:12)
at parseType (/app/node_modules/redis-parser/lib/parser.js:302:14) {
command: { name: 'select', args: [ 'NaN' ] }
}
My Redis.yaml file like that:
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-depl
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:6.0.12
---
apiVersion: v1
kind: Service
metadata:
name: redis-srv
spec:
selector:
app: redis
ports:
- name: redis
protocol: TCP
port: 6379
targetPort: 6379
And my Redis connection like that:
const redis_url = "redis://redis-srv:6379";
let myStatsQueue = new Queue('statistics', redis_url);
myStatsQueue.on('global:completed', (jobId, result) => {
//...
});
Why I getting this error? How can I solve this error?
if you're sure that your host is correct, try adding db number to URL so it will be: const redis_url = "redis://redis-srv:6379/0";
(0 is default db for redis), maybe this lib doesn't fallback to default db