문제 인식

Docker Container 환경에서 게임 서버 실행 시, Bull Queue 작업 추가에 문제가 발생했습니다.

🚫 문제점

원인 파악

게임 서버 Bull Queue 작업 로그

스크린샷 2024-08-24 211843.png

🔍 분석

해결 과정

Redis Client 변경

// 기존 코드
import redis from 'redis';

const redisClient = redis.createClient({
   url: `redis://${config.redis.redisUsername}:${config.redis.redisPassword}@${config.redis.redisHost}:${config.redis.redisPort}/0`,
 });
// 변경 코드
import Redis from 'ioredis';

const redisClient = new Redis({
  port: config.redis.redisPort,
  host: config.redis.redisHost,
  username: config.redis.redisUsername,
  password: config.redis.redisPassword,
  db: 0,
  maxRetriesPerRequest: null,
  enableReadyCheck: true,
});

Bull Queue 생성 시 Redis Client 전달 로직 수정

const monsterHitQueue = new Bull('MONSTER_HIT_QUEUE_NAME', {
  redis: {
    host: config.redis.redisHost,
    port: config.redis.redisPort,
  },
});