File tree Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Expand file tree Collapse file tree 2 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import { Registry } from 'prom-client';
6
6
import { createClient } from 'redis' ;
7
7
8
8
import { Utils } from '../../../utils' ;
9
- import { RedisCacheError } from '../../errors/RedisCacheError' ;
10
9
import { IRedisCacheClient } from './IRedisCacheClient' ;
11
10
12
11
/**
@@ -51,15 +50,6 @@ export class RedisCache implements IRedisCacheClient {
51
50
this . logger = logger ;
52
51
this . register = register ;
53
52
this . client = client ;
54
-
55
- this . client . on ( 'error' , ( error ) => {
56
- const redisError = new RedisCacheError ( error ) ;
57
- if ( redisError . isSocketClosed ( ) ) {
58
- logger . error ( `Error occurred with Redis Connection when closing socket: ${ redisError . message } ` ) ;
59
- } else {
60
- logger . error ( `Error occurred with Redis Connection: ${ redisError . fullError } ` ) ;
61
- }
62
- } ) ;
63
53
}
64
54
65
55
async getConnectedClient ( ) : Promise < ReturnType < typeof createClient > > {
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import { HbarSpendingPlanRepository } from './db/repositories/hbarLimiter/hbarSp
17
17
import { IPAddressHbarSpendingPlanRepository } from './db/repositories/hbarLimiter/ipAddressHbarSpendingPlanRepository' ;
18
18
import { DebugImpl } from './debug' ;
19
19
import { RpcMethodDispatcher } from './dispatcher' ;
20
+ import { RedisCacheError } from './errors/RedisCacheError' ;
20
21
import { EthImpl } from './eth' ;
21
22
import { NetImpl } from './net' ;
22
23
import { CacheService } from './services/cacheService/cacheService' ;
@@ -364,10 +365,17 @@ export class Relay {
364
365
redisClient . on ( 'ready' , ( ) => {
365
366
this . logger . info ( `Redis client connected to ${ redisUrl } ` ) ;
366
367
} ) ;
368
+ redisClient . on ( 'end' , ( ) => {
369
+ this . logger . info ( 'Disconnected from Redis server!' ) ;
370
+ } ) ;
367
371
redisClient . on ( 'error' , ( error ) => {
368
- this . logger . error ( error , 'Redis connection could not be established!' ) ;
372
+ const redisError = new RedisCacheError ( error ) ;
373
+ if ( redisError . isSocketClosed ( ) ) {
374
+ this . logger . error ( `Error occurred with Redis Connection when closing socket: ${ redisError . message } ` ) ;
375
+ } else {
376
+ this . logger . error ( `Error occurred with Redis Connection: ${ redisError . fullError } ` ) ;
377
+ }
369
378
} ) ;
370
-
371
379
return redisClient ;
372
380
}
373
381
}
You can’t perform that action at this time.
0 commit comments