redis / ioredis

🚀 A robust, performance-focused, and full-featured Redis client for Node.js.
MIT License
14.06k stars 1.19k forks source link

Protocol error, got "H" as reply type byte. #1862

Open troykelly opened 4 months ago

troykelly commented 4 months ago

Connecting to Redis over TLS generates:

[ioredis] Unhandled error event: ParserError: Protocol error, got "H" as reply type byte. Please report this.
    at handleError (/workspaces/shop-fail/node_modules/redis-parser/lib/parser.js:190:15)
    at parseType (/workspaces/shop-fail/node_modules/redis-parser/lib/parser.js:304:14)

Given redis-parser is unmaintained (for six years now), it seems counter productive to log the issue there.

troykelly commented 4 months ago

This is related to https://github.com/redis/ioredis/pull/1137 I assume because it's tls requiring sni that ioredis is having the issue.

troykelly commented 4 months ago

Resolved by passing servername

    // Redis client configuration
    const redisHost = process.env.REDIS_HOST || 'redis'
    const redisPassword = process.env.REDIS_PASSWORD || ''
    // is "REDIS_TLS" truthy
    const redisTls: ConnectionOptions | undefined = process.env.REDIS_TLS
      ? { servername: redisHost }
      : undefined
    const redisOptions: RedisOptions = {
      host: redisHost,
      password: redisPassword,
      tls: redisTls
    }

    this.redisClient = new Redis(redisOptions)