Node-redis: 3 ๋ถ„๋งˆ๋‹ค ECONNRESET ์ฝ๊ธฐ-์ด๋กœ ์ธํ•ด NodeJS ์„œ๋ฒ„๊ฐ€ ์ถฉ๋Œํ•ฉ๋‹ˆ๋‹ค. ์„œ๋ฒ„ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ์œ„ํ•ด newrelic ํ”Œ๋Ÿฌ๊ทธ์ธ ์‚ฌ์šฉ.

์— ๋งŒ๋“  2015๋…„ 02์›” 09์ผ  ยท  26์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: NodeRedis/node-redis

์˜ค๋ฅ˜ : redis1.tfs์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ์ž…๋‹ˆ๋‹ค. tfs : 6379 ์‹คํŒจ-์†Œ์ผ“์˜ RedisClient.on_error (/var/www/a/b/c/node_modules/redis/index.js:196:24)์—์„œ ECONNRESET์„ ์ฝ์Šต๋‹ˆ๋‹ค.(/var/www/a/b/c/node_modules/redis/index.js:106:14)
Socket.emit (events.js : 95 : 17)
net.js : 441 : 14์—์„œ
/var/www/a/b/c/node_modules/newrelic/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
/var/www/a/b/c/node_modules/newrelic/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
process._tickDomainCallback์—์„œ (node.js : 486 : 13)
๊ณผ์ •์—์„œ.(/var/www/a/b/c/node_modules/newrelic/node_modules/continuation-local-storage/node_modules/async-listener/index.js:18:15)

question

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

@ ayazpasha2434 ์ด ์ค„์€ ๋‚ด ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.

client.on ( 'error', function (err) {console.error (err)})

๋ชจ๋“  26 ๋Œ“๊ธ€

๋‚˜์—๊ฒŒ ์ด๊ฒƒ์€ Node.js ์™ธ๋ถ€์˜ ๋„คํŠธ์›Œํ‚น ๋ฌธ์ œ์ฒ˜๋Ÿผ ๋“ค๋ฆฝ๋‹ˆ๋‹ค.์ด ์˜ค๋ฅ˜ "ECONNRESET"์€ Node.js์— ๋Œ€ํ•œ ์›๊ฒฉ ์—ฐ๊ฒฐ์ด ์†Œ์ผ“์„ ์˜ˆ๊ธฐ์น˜ ์•Š๊ฒŒ ๋‹ซ์„ ๋•Œ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

Node์™€ Redis๊ฐ„์— ํ”„๋ก์‹œ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๊นŒ?

Node / node_redis / Redis ์„œ๋ฒ„์˜ ๋ฒ„์ „์€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?

NewRelic ์—์ด์ „ํŠธ๊ฐ€ ๊ด€๋ จ๋˜์–ด ์žˆ๋Š”์ง€ ์˜์‹ฌ ์Šค๋Ÿฝ์ง€๋งŒ ์—์ด์ „ํŠธ์—†์ด ํ•ญ์ƒ ๋ณต์ œ๋ฅผ ์‹œ๋„ํ•˜์—ฌ ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋˜๋Š”์ง€ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. cc / @wraithan

๊ทธ ๋ผ์ธ์€ CLS๊ฐ€ํ•˜๋Š” ์ผ์ž…๋‹ˆ๋‹ค. ๋” ๋งŽ์€ ์žฌํ˜„์„ ํ†ตํ•ด New Relic ์—์ด์ „ํŠธ๋ฅผ ์™„์ „ํžˆ ๋ฐฐ์ œ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋‚˜๋Š” ์ด๊ฒƒ์ด ์šฐ๋ฆฌ์— ์˜ํ•œ ๊ฒƒ์ด ์•„๋‹ˆ๋ผ๊ณ  ์ƒ๋Œ€์ ์œผ๋กœ ํ™•์‹ ํ•ฉ๋‹ˆ๋‹ค.

NewRelic ์—์ด์ „ํŠธ๋ฅผ ์ œ๊ฑฐ ํ–ˆ๋Š”๋ฐ๋„ ๋ฌธ์ œ๊ฐ€ ๊ณ„์† ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ๋Œ€๋žต. 3 ๋ถ„๋งˆ๋‹ค์ด ์ถฉ๋Œ์ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜๋Š” ์ฐธ๊ณ  ์šฉ ๋กœ๊ทธ์ž…๋‹ˆ๋‹ค.

events.js : 72
์–ด ๋˜์ ธ; // ์ฒ˜๋ฆฌ๋˜์ง€ ์•Š์€ '์˜ค๋ฅ˜'์ด๋ฒคํŠธ
^
์˜ค๋ฅ˜ : redis1.tfs์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ์ž…๋‹ˆ๋‹ค. tfs : 6379 ์‹คํŒจ
RedisClient.on_error (/var/www/a/b/c/node_modules/redis/index.js:196:24)
์†Œ์ผ“์—์„œ.(/var/www/a/b/c/node_modules/redis/index.js:106:14)
Socket.emit (events.js : 95 : 17)
net.js : 441 : 14์—์„œ
process._tickDomainCallback์—์„œ (node.js : 486 : 13)
์˜ค๋ฅ˜ : ์˜์›ํžˆ ๊ฐ์ง€ ๋œ ์Šคํฌ๋ฆฝํŠธ๊ฐ€ ์ฝ”๋“œ๋กœ ์ข…๋ฃŒ ๋จ : 8
์˜ค๋ฅ˜ : ์Šคํฌ๋ฆฝํŠธ ๋‹ค์‹œ ์‹œ์ž‘ ์‹œ๋„ # 50

๋˜ํ•œ Node.JS-v0.10.35, node_redis-0.12.1 ๋ฐ Redis-2.8.4๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
Node.js์—์„œ IP๋ฅผ ํ†ตํ•ด ์ง์ ‘ Redis์— ์•ก์„ธ์Šคํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

๋‚˜๋„์ด ๋ฌธ์ œ์— ์ง๋ฉดํ•˜๊ณ  ์žˆ์—ˆ์ง€๋งŒ, ์–ด์ œ ๋‹ค๋ฅธ ์ด์œ ๋กœ /etc/hosts ํŒŒ์ผ์„ ๊ฐ€์ง€๊ณ  ๋†€์•˜๋‹ค๋Š” ๊ฒƒ์„ ๊นจ๋‹ฌ์€ ํ›„์— ํ•ด๊ฒฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋ˆ„๋ฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

127.0.0.1 localhost

@ ayazpasha2434 ์†”๋ฃจ์…˜์€ ๋‹น์‹ ์—๊ฒŒ ๋™์ผํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ์ง€๋งŒ ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์ด ์•”์‹œํ•˜๋Š” ๊ฒƒ์ฒ˜๋Ÿผ

@sarathms ๋‚ด ํ˜ธ์ŠคํŠธ ํŒŒ์ผ์—์ด ๋งคํ•‘์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์ œ ๊ฒฝ์šฐ์—๋Š” Redis ์‹œ์Šคํ…œ์ด ์›๊ฒฉ ์‹œ์Šคํ…œ์ž…๋‹ˆ๋‹ค. ๊ต์ฐจ ํ™•์ธํ•œ ํ›„ Redis ์ปดํ“จํ„ฐ์—๋„ ํ•ด๋‹น ๋กœ์ปฌ ํ˜ธ์ŠคํŠธ ๋งคํ•‘์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ์ „ํžˆ ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.

๋‚˜๋Š” ๋˜ํ•œ ๊ฐ™์€ ๋ฌธ์ œ์— ์ง๋ฉดํ•˜๊ณ ์žˆ๋‹ค. ๋‹ค์Œ์€ ์ฝ˜์†” ์ถœ๋ ฅ์ž…๋‹ˆ๋‹ค.

events.js : 72
์–ด ๋˜์ ธ; // ์ฒ˜๋ฆฌ๋˜์ง€ ์•Š์€ '์˜ค๋ฅ˜'์ด๋ฒคํŠธ
^
์˜ค๋ฅ˜ : pub-redis-10606.us-east-1-1.1.ec2.garantiadata์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ. com : 10606 ์‹คํŒจ-RedisClient.on_error์—์„œ ECONNRESET ์ฝ๊ธฐ (C : \ Users \ Gigi \ Desktop \ eduknow_api_ver_1authnode_m
odulesredisindex.js : 196 : 24)
์†Œ์ผ“์—์„œ.(C : \ Users \ Gigi \ Desktop \ eduknow_api_ver_1authnode_modulesredisindex.js : 106 : 14)
Socket.emit (events.js : 95 : 17)
net.js : 441 : 14์—์„œ
process._tickCallback์—์„œ (node.js : 442 : 13)

@ ayazpasha2434 ์ด ์ค„์€ ๋‚ด ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.

client.on ( 'error', function (err) {console.error (err)})

@ ayazpasha2434 @Waterloo ๊ฐ€ ๋‹น์‹ ์—๊ฒŒ ๋งž๋Š” ๋‹ต์„ ๊ฐ€์ง€๊ณ  ์žˆ์—ˆ ์Šต๋‹ˆ๊นŒ?

๋„คํŠธ์›Œํฌ ์—ฐ๊ฒฐ์— ๋ฌธ์ œ๊ฐ€์žˆ๋Š” ๊ฒƒ ๊ฐ™๊ณ  ๋…ธ๋“œ redis์— ๋ฌธ์ œ๊ฐ€์—†๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ๊ธฐ๋ฅผ ์ถ”๊ฐ€ํ•˜๋ฉด ์•ฑ์ด ๋” ์ด์ƒ ์ถฉ๋Œํ•˜์ง€ ์•Š๋„๋ก ์ถฉ๋ถ„ํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค (ํ•ญ์ƒ ์—ฐ๊ฒฐ๋˜์–ด์•ผ ํ•จ).

์ž๋ฐ” ์„œ๋ฒ„์— http (ํฌ์ŠคํŠธ ์‚ฌ์šฉ)๋ฅผ ์˜ฌ๋ฆด ๋•Œ์ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค. {[์˜ค๋ฅ˜ : ECONNRESET ์ฝ๊ธฐ]
์ฝ”๋“œ : 'ECONNRESET',
์˜ค๋ฅ˜ ๋ฒˆํ˜ธ : 'ECONNRESET',
syscall : '์ฝ๊ธฐ',
์‘๋‹ต : ์ •์˜๋˜์ง€ ์•Š์Œ}
์˜ค๋ฅ˜ : ECONNRESET ์ฝ๊ธฐ
exports._errnoException (util.js : 856 : 11)
TCP.onread (net.js : 546 : 26)
์ด์ค‘ ์ฝœ๋ฐฑ!
POST / user_archives / create / save 500 45.306ms-386
์˜ค๋ฅ˜ : ECONNRESET ์ฝ๊ธฐ
exports._errnoException (util.js : 856 : 11)
TCP.onread (net.js : 546 : 26)

@ biggu0 ์ด๊ฒƒ์ด node_redis์™€ ์–ด๋–ค ์—ฐ๊ฒฐ์ธ์ง€ ์ž˜ ๋ชจ๋ฅด๊ฒ ์Šต๋‹ˆ๋‹ค. ECONNRESET ์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„ ๋ณด๋ ค๋ฉด stackoverflow๋ฅผ ์ฐธ์กฐํ•˜์‹ญ์‹œ์˜ค .

์•ˆ๋…• ,
์šฐ๋ฆฌ๋Š” ๋˜ํ•œ์ด ๋ฌธ์ œ๋ฅผ๋ณด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. redis SNAPSHOTTING ๋•Œ๋ฌธ์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. redis๊ฐ€ ์Šค๋ƒ… ์ƒท์„ ์ฐ๊ณ  ๋””์Šคํฌ ์—ฐ๊ฒฐ์— ์ €์žฅํ•  ๋•Œ๋งˆ๋‹ค ์žฌ์„ค์ •๋ฉ๋‹ˆ๋‹ค. ์ž์‹ ์„ ์ฆ๋ช…ํ•˜๊ธฐ ์œ„ํ•ด ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ๋กœ๊ทธ๋ฅผ redis ๋””๋ฒ„๊ทธ ๋กœ๊ทธ์™€ ๋น„๊ตํ•˜๊ณ  ํƒ€์ด๋ฐ์ด ์ •ํ™•ํžˆ ์ผ์น˜ํ•ฉ๋‹ˆ๋‹ค.

์•„๋ž˜๋Š” redis.conf์˜ ์Šค๋ƒ… ์ƒท ์„ค์ •์ž…๋‹ˆ๋‹ค.
900 ์ €์žฅ 1
300 10 ์ ˆ์•ฝ
60 10000 ์ ˆ์•ฝ

์šฐ๋ฆฌ๊ฐ€ ๋ญ”๊ฐ€ ์ž˜๋ชปํ•˜๊ณ  ์žˆ๋‹ค๋ฉด ์•Œ๋ ค์ฃผ์‹ญ์‹œ์˜ค.

๋‚˜๋Š” ๋˜ํ•œ ์ž์ฃผ ์—ฐ๊ฒฐ ๋ฌธ์ œ์— ์ง๋ฉดํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

RedisClient.emit์˜ ERR (events.js : 188 : 7)
RedisClient.on_error์˜ ์˜ค๋ฅ˜ (/home/vcap/app/node_modules/redis/index.js:394:14)
RedisClient์—์„œ ERR์ž…๋‹ˆ๋‹ค.(/home/vcap/app/server.js:28:13)
emitErrorNT์˜ ERR (net.js : 1281 : 8)
์†Œ์ผ“์—์„œ ERR.(/home/vcap/app/node_modules/redis/index.js:272:14)
process._tickCallback์˜ ERR (๋‚ด๋ถ€ / ํ”„๋กœ์„ธ์Šค /next_tick.js:98:9)
์˜ค๋ฅ˜ ์˜ค๋ฅ˜ : XXXXXXXX : XXXXX์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ ์‹คํŒจ-ECONNRESET ์ฝ๊ธฐ
TCP.onread์—์„œ ERR (net.js : 572 : 26)
_combinedTickCallback์˜ ERR (๋‚ด๋ถ€ / ํ”„๋กœ์„ธ์Šค /next_tick.js:74:11)
emitOne์˜ ERR (events.js : 96 : 13)
exports._errnoException์—์„œ ERR (util.js : 1022 : 11)
Socket.emit์˜ ERR (events.js : 188 : 7)

์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ์ž๋™์œผ๋กœ ๋‹ค์‹œ ์—ฐ๊ฒฐ๋ฉ๋‹ˆ๋‹ค.
์—ฐ๊ฒฐ์ด ๋Š์–ด์ง€๋ฉด ๋ฌธ์ œ๊ฐ€ ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์•ˆ๋…•ํ•˜์„ธ์š” ์›Œํ„ธ๋ฃจ,
์ด ๋ฌธ์„ ๋„ฃ๋Š” ์œ„์น˜ client.on ( 'error', function (err) {console.error (err)})
๊ทธ๋ฆฌ๊ณ  ๋‚˜๋Š”์ด ์ง„์ˆ ์ด ๋‹น์‹ ์˜ ์˜ค๋ฅ˜๋ฅผ ์œ„๋กœํ•˜๊ธฐ ์œ„ํ•ด ๋‹ค๋ฅธ ๊ฒƒ์€ ์—†๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
์ •๋ง ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?
์ตœ๋Œ€ํ•œ ๋นจ๋ฆฌ ๋‹น์‹ ์˜ ์ƒ๊ฐ์„์ฃผ์‹ญ์‹œ์˜ค.

๋ฏธ๋ฆฌ ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค !!!

์•ˆ๋…•ํ•˜์„ธ์š”

๋‚˜๋„ ๊ฐ™์€ ๋ฌธ์ œ์— ์ง๋ฉดํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค

events.js : 160
์–ด ๋˜์ ธ; // ์ฒ˜๋ฆฌ๋˜์ง€ ์•Š์€ '์˜ค๋ฅ˜'์ด๋ฒคํŠธ
^

์˜ค๋ฅ˜ : ECONNRESET ์ฝ๊ธฐ

์ด๊ฒƒ์€ ๋‚ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค.

  1. ๋ชจ๋“  ํ”„๋กœ์„ธ์Šค ๋ชจ๋‹ˆํ„ฐ๋ง์„ ๋น„ํ™œ์„ฑํ™”ํ–ˆ์Šต๋‹ˆ๋‹ค (new relic, elastic apm ...).
  2. ์ด ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.
    ```์ž๋ฐ” ์Šคํฌ๋ฆฝํŠธ
    process.on ( 'uncaughtException', function (err) {
    console.error (err.stack);
    console.log ( "๋…ธ๋“œ ์ข…๋ฃŒ๋˜์ง€ ์•Š์Œ ...");
    });

๋‚˜๋Š” ๋˜ํ•œ์ด ๋ฌธ์ œ์— ์ง๋ฉดํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํ›„ํฌ๊ฐ€์žˆ๋Š” sails.js ํ”„๋ ˆ์ž„ ์›Œํฌ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์œผ๋ฏ€๋กœ ๋…ธ๋“œ ์„œ๋น„์Šค๋ฅผ ์‹œ์ž‘ํ•  ๋•Œ redis ์„œ๋ฒ„์— ๋Œ€ํ•œ ์—ฐ๊ฒฐ์ด ํ•˜๋‚˜๋ฟ์ด๋ฏ€๋กœ ์ „์—ญ sails ๊ฐœ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ redis์— ์•ก์„ธ์Šคํ•˜๊ณ  ์ž‘์—…ํ•ฉ๋‹ˆ๋‹ค.

redisClient = redis.createClient({
    host: redisConfig.host,
    port: redisConfig.port,
    db: redisConfig.db,
    retry_strategy: (retryOptions) => {
        if (retryOptions.error && retryOptions.error.code === 'ECONNREFUSED') {
            // End reconnecting on a specific error and flush all commands with
            // a individual error
            return new Error('The server refused the connection');
        }

        if (retryOptions.total_retry_time > 1000 * 60 * 60) {
            // End reconnecting after a specific timeout and flush all commands
            // with a individual error
            return new Error('Retry time exhausted');
        }

        if (retryOptions.attempt > 3) {
            // End reconnecting with built in error
            return undefined;
        }

        sails.log.debug('Handling redis retry strategy', {
            error: retryOptions.error,
            totalRetryTime: retryOptions.total_retry_time,
            attempt: retryOptions.attempt
        });

        // Reconnect after
        return Math.min(retryOptions.attempt * 100, 3000);
    }
});

๋‹ค์Œ์€ ์˜ค๋ฅ˜์˜ ์Šคํƒ ์ถ”์ ์ž…๋‹ˆ๋‹ค.
AbortError : Redis ์—ฐ๊ฒฐ์ด ๋Š์–ด์ง€๊ณ  ๋ช…๋ น์ด ์ค‘๋‹จ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. RedisClient.flush_and_error (/var/sample-app/node_modules/redis/index.js:362:23)์—์„œ ์ฒ˜๋ฆฌ๋˜์—ˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค .n RedisClient.connection_gone (/ var / sample-app / node_modules / redis / index. RedisClient.on_error (/var/sample-app/node_modules/redis/index.js:410:10)์—์„œ n ์†Œ์ผ“ .js : 664 : 14) n(/var/sample-app/node_modules/redis/index.js:279:14)n at emitOne (events.js : 116 : 13) n at Socket.emit (events.js : 211 : 7) n at emitErrorNT ( internal / streams / destroy.js : 66 : 8) n at /var/sample-app/node_modules/async-listener/glue.js:188:31n at args. (anonymous function) (/ usr / lib / node_modules / pm2 /node_modules/event-loop-inspector/index.js:138:29)n at _combinedTickCallback (internal / process / next_tick.js : 139 : 11) n at process._tickDomainCallback (internal / process / next_tick.js : 219 : 9 ) n at process.fallback (/var/sample-app/node_modules/async-listener/index.js:563:15).

๋…ธ๋“œ ์•ฑ์€ Docker ์ปจํ…Œ์ด๋„ˆ์—์„œ ์‹คํ–‰๋˜๋ฉฐ EC2 Linux ์ธ์Šคํ„ด์Šค์— ์„ค์น˜๋œ Redis ์„œ๋ฒ„์— ์—ฐ๊ฒฐ๋ฉ๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๋„ ๊ฐ™์€ ๋ฌธ์ œ์— ์ง๋ฉดํ–ˆ์ง€๋งŒ ์—ฌ๊ธฐ์— stunnel ๊ตฌ์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ redis๋ฅผ localhost์— ํ”„๋ก์‹œํ•˜๋Š” stunnel์„ ๋ฐฐ์น˜ํ–ˆ์Šต๋‹ˆ๋‹ค.

fips = ์•„๋‹ˆ์˜ค

setuid = ๋ฃจํŠธ

setgid = ๋ฃจํŠธ

pid = /var/run/stunnel.pid
๋””๋ฒ„๊ทธ = 7

์˜ต์…˜ = NO_SSLv2

์˜ต์…˜ = NO_SSLv3
์ถœ๋ ฅ = /var/log/stunnel.log

ํด๋ผ์ด์–ธํŠธ = ์•„๋‹ˆ์˜ค

์ „๊ฒฝ = ์˜ˆ

[redis-cli]
ํด๋ผ์ด์–ธํŠธ = ์˜ˆ
์ˆ˜๋ฝ = 127.0.0.1:6379
์—ฐ๊ฒฐ = redi sendpoint : 6379

๋…ธ๋“œ๊ฐ€ ๋ช‡ ๋ถ„๋งˆ๋‹ค ์•„๋ž˜ ์˜ค๋ฅ˜๋กœ ์—ฐ๊ฒฐ์ด ๋Š์–ด์ง‘๋‹ˆ๋‹ค. Docker ์ปจํ…Œ์ด๋„ˆ๋ฅผ ํ†ตํ•ด ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

127.0.0.1:6379์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ ์‹คํŒจ-ECONNRESET ์ฝ๊ธฐ
TCP.onStreamRead (internal / stream_base_commons.js : 111 : 27)์—์„œ
์˜ค๋ฅ˜ : 127.0.0.1:6379์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ ์‹คํŒจ-ECONNRESET ์ฝ๊ธฐ
TCP.onStreamRead (internal / stream_base_commons.js : 111 : 27)์—์„œ
์˜ค๋ฅ˜ : 127.0.0.1:6379์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ ์‹คํŒจ-ECONNRESET ์ฝ๊ธฐ
TCP.onStreamRead (internal / stream_base_commons.js : 111 : 27)์—์„œ
AbortError : Redis ์—ฐ๊ฒฐ์ด ๋Š์–ด์ง€๊ณ  ๋ช…๋ น์ด ์ค‘๋‹จ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒ˜๋ฆฌ๋˜์—ˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์–ด๋–ค ํ•ด์ƒ๋„?

์šฐ๋ฆฌ๋„ ๊ฐ™์€ ๋ฌธ์ œ์— ์ง๋ฉดํ–ˆ์ง€๋งŒ ์—ฌ๊ธฐ์— stunnel ๊ตฌ์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ redis๋ฅผ localhost์— ํ”„๋ก์‹œํ•˜๋Š” stunnel์„ ๋ฐฐ์น˜ํ–ˆ์Šต๋‹ˆ๋‹ค.

fips = ์•„๋‹ˆ์˜ค

setuid = ๋ฃจํŠธ

setgid = ๋ฃจํŠธ

pid = /var/run/stunnel.pid
๋””๋ฒ„๊ทธ = 7

์˜ต์…˜ = NO_SSLv2

์˜ต์…˜ = NO_SSLv3
์ถœ๋ ฅ = /var/log/stunnel.log

ํด๋ผ์ด์–ธํŠธ = ์•„๋‹ˆ์˜ค

์ „๊ฒฝ = ์˜ˆ

[redis-cli]
ํด๋ผ์ด์–ธํŠธ = ์˜ˆ
์ˆ˜๋ฝ = 127.0.0.1:6379
์—ฐ๊ฒฐ = redi sendpoint : 6379

๋…ธ๋“œ๊ฐ€ ๋ช‡ ๋ถ„๋งˆ๋‹ค ์•„๋ž˜ ์˜ค๋ฅ˜๋กœ ์—ฐ๊ฒฐ์ด ๋Š์–ด์ง‘๋‹ˆ๋‹ค. Docker ์ปจํ…Œ์ด๋„ˆ๋ฅผ ํ†ตํ•ด ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

127.0.0.1:6379์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ ์‹คํŒจ-ECONNRESET ์ฝ๊ธฐ
TCP.onStreamRead (internal / stream_base_commons.js : 111 : 27)์—์„œ
์˜ค๋ฅ˜ : 127.0.0.1:6379์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ ์‹คํŒจ-ECONNRESET ์ฝ๊ธฐ
TCP.onStreamRead (internal / stream_base_commons.js : 111 : 27)์—์„œ
์˜ค๋ฅ˜ : 127.0.0.1:6379์— ๋Œ€ํ•œ Redis ์—ฐ๊ฒฐ ์‹คํŒจ-ECONNRESET ์ฝ๊ธฐ
TCP.onStreamRead (internal / stream_base_commons.js : 111 : 27)์—์„œ
AbortError : Redis ์—ฐ๊ฒฐ์ด ๋Š์–ด์ง€๊ณ  ๋ช…๋ น์ด ์ค‘๋‹จ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ฒ˜๋ฆฌ๋˜์—ˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์–ด๋–ค ํ•ด์ƒ๋„?

๋‚˜์—๊ฒŒ๋„ ์ด๊ฒƒ์ด stunnel์˜ ๋ฌธ์ œ๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

๋‚˜๋Š” ๋˜ํ•œ ๊ฐ™์€ ์˜ค๋ฅ˜์— ์ง๋ฉดํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค

{ Error: Redis connection to xx.xx.x.x:6379 failed - read ECONNRESET" 

at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' 

๋‚˜๋Š” ๋˜ํ•œ ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ๊ธฐ๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์ง€๋งŒ ์™œ ์ด๋Ÿฐ ์ผ์ด ๋ฐœ์ƒํ•˜๋Š”์ง€, ์ฟผ๋ฆฌ ํ˜ธ์ถœ์— ์˜ํ–ฅ์„ ๋ฏธ์น˜๊ณ  ๋‚ด ์š”์ฒญ์„ ์ง€์—ฐ์‹œํ‚ฌ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

@Ayaz ์ด ๋ฌธ์ œ๋Š” ์™„์ „ํžˆ ํ•ด๊ฒฐ๋˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ๋žŒ๋“ค์ด ์˜ค๋ฅ˜ ์‘๋‹ต ๋งŒ ์ฒ˜๋ฆฌํ–ˆ์ง€๋งŒ ๋ฌธ์ œ๋Š” ์—ฌ์ „ํžˆ ํ•ด๊ฒฐ๋˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์—์ด ๋ฌธ์ œ๋ฅผ ์—ด โ€‹โ€‹์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

๋ฒ”ํ•‘ : ์—ฌ๊ธฐ์— ๊ฐ™์€ ๋ฌธ์ œ :

error: Error: Redis connection to xx.yy.zz.aa:6379 failed - read ECONNRESET at TCP.onStreamRead (internal/stream_base_commons.js:205:27) { errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' },

๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

  • NodeJS v12.16.3
  • NestJS ํ”„๋ ˆ์ž„ ์›Œํฌ
  • Ioredis : 4.2
  • nestjs-redis : 1.2.8

Redis๋Š” Google Cloud MemoryStore๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค.

๋กœ๊ทธ์—๋Š” ๋‹ค์Œ์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

[ioredis] ์ฒ˜๋ฆฌ๋˜์ง€ ์•Š์€ ์˜ค๋ฅ˜ ์ด๋ฒคํŠธ : ์˜ค๋ฅ˜ : ECONNRESET ์ฝ๊ธฐ

์ด๊ฒƒ์€ ํŠน๋ณ„ํ•œ ์ด์œ ๋‚˜ ๋™์ผํ•œ ๋‹จ๊ณ„์—†์ด 24 ์‹œ๊ฐ„๋งˆ๋‹ค ํ•œ ๋ฒˆ์”ฉ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

๋ฟก๋ฟก
๋‚˜๋Š” ๊ฐ™์€ ๋ฌธ์ œ๋ฅผ ๋ณธ๋‹ค. Redis๋Š” Google Cloud MemoryStore๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ œ๊ณต๋ฉ๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜์…จ์Šต๋‹ˆ๊นŒ?

๋˜ํ•œ Cloud Memory Store์— ์—ฐ๊ฒฐํ•  ๋•Œ Cloud run / Cloud Functions์—์„œ ๋งค์šฐ ์œ ์‚ฌํ•œ ๋ฌธ์ œ๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ ๋ฆฌ์†Œ์Šค๊ฐ€ Google์— ์˜ํ•ด ๋„ˆ๋ฌด ๋นจ๋ฆฌ ์ž„์˜๋กœ ์ค‘์ง€ ๋  ๋•Œ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด ๋ฌธ์ œ๋Š” Redis ์—ฐ๊ฒฐ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณ€๊ฒฝํ•˜์ง€ ์•Š๊ณ  ์•ฝ ์ผ์ฃผ์ผ ์ „์— ์‹œ์ž‘๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ioredis๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฐ๊ฒฐ์„ ์ฒ˜๋ฆฌํ•˜๊ณ  ๋…ธ๋“œ 12๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

IORedis๋Š” ๊ธฐ๋ณธ ์ „๋žต์œผ๋กœ ์˜ค๋ฅ˜ ๋ฐœ์ƒ์‹œ ์žฌ ์—ฐ๊ฒฐ์„ ์ œ๊ณตํ•˜์ง€๋งŒ ์–ด๋–ค ์ด์œ ๋กœ ๋“  ๋ฐœ์ƒํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

๋‚ด๊ฐ€ ํ•œ ๊ฒƒ์€ ๊ตฌ์„ฑ์— ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

reconnectOnError: (error): boolean => {
  console.log('Always reconnect on error', error)
  return true
}

ECONNRESET ์˜ค๋ฅ˜๊ฐ€ ์—ฌ์ „ํžˆ ์กด์žฌํ•˜์ง€๋งŒ ์ด์ œ ์—ฐ๊ฒฐ์ด ๋‹ค์‹œ ์‹œ๋„๋˜๊ณ  ๋‚ด Google ์ธ์Šคํ„ด์Šค๊ฐ€ ๋” ์ด์ƒ ๋ฉˆ์ถฐ ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

CC : @ hkd987

reconnectOnError ์— ๋Œ€ํ•œ ์ž์„ธํ•œ ๋‚ด์šฉ์€ https://github.com/luin/ioredis์—์„œ ํ™•์ธํ•˜์„ธ์š”.

@ robertop87 ํ•ญ์ƒ reconnectOnError true๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ์„ค์ •๋œ ํŠน์ • ๊ตฌ์„ฑ์œผ๋กœ ์ƒˆ ๋ฐฐํฌ๋ฅผ ์ˆ˜ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฒƒ์€ ์ตœ์‹  ๋ฆด๋ฆฌ์Šค์—์„œ ๋ฐœ์ƒํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋‹ค์‹œ ์—ด๊ฑฐ ๋‚˜ ์ƒˆ ํ‹ฐ์ผ“์„ ๋งŒ๋“ค์–ด์•ผํ•˜๋Š” ๋ฌธ์ œ์ฒ˜๋Ÿผ ๋ณด์ž…๋‹ˆ๋‹ค.

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰