سلام. وقت بخیر.
من redis رو روی لینوکس نصب کردم. کد مربوط به session handler redis:
let redis = require('redis'); module.exports = (session) => { let RedisStore = require('connect-redis')(session); let redisClient = redis.createClient(); return new RedisStore({ client: redisClient }); }
کد مربوط به اتصال session به app
const express = require('express'); const session = require('express-session'); const cookieParser = require('cookie-parser'); const flash = require('req-flash'); const sessionStore = require('@bootstrap/session-handler/redis')(session); const app = express(); require('./bootstrap')(app); app.use(cookieParser()); app.use(session({ store: sessionStore, saveUninitialized: false, secret: 'fs984urf09pu4r4fk345pf', resave: false, name: 'my-simple-blog-session' })); app.use(flash()); require('@middlewares')(app); require('@routes')(app); module.exports = () => { const port = process.env.APP_PORT; app.listen(port, () => { console.log('listening on port ' + port); }) }
این ارور رو دریافت میکنم:
/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/@node-redis/client/dist/lib/client/index.js:393 return Promise.reject(new errors_1.ClientClosedError()); ^ ClientClosedError: The client is closed at Commander._RedisClient_sendCommand (/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/@node-redis/client/dist/lib/client/index.js:393:31) at Commander.commandsExecutor (/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/@node-redis/client/dist/lib/client/index.js:160:154) at Commander.BaseClass. [as get] (/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/@node-redis/client/dist/lib/commander.js:8:29) at RedisStore.get (/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/connect-redis/lib/connect-redis.js:33:19) at session (/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/express-session/index.js:485:11) at Layer.handle [as handle_request] (/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/express/lib/router/index.js:317:13) at /home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/express/lib/router/index.js:335:12) at next (/home/ma90/NodeJS Projects/simple-blog-nodejs-express/node_modules/express/lib/router/index.js:275:10) [nodemon] app crashed - waiting for file changes before starting...
خیلی سرچ کردم ولی به نتیجه نرسیدم.
چجوری میتونم این مشکل رو حل کنم؟
روی ترمینال که از redis تست میگیرم مشکلی نداره ران شده.