我有一个问题,每当我试图明星使用npm开始
它给了我这个警告
Error: Redis connection to redis-adapter:6379 failed - getaddrinfo EAI_AGAIN redis-adapter redis-adapter:6379
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
我已经在终端检查了我的redis,它已经启动了
这是我的配置文件夹中的server.js/index.js和express.js
服务器.js
import app from './config/express';
app.listen(process.env.PORT, () => {
console.log(`hei udah masuk ke port ini ${process.env.PORT}`);
});
这是我的快递
// import express from 'express';
import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
// import routes from '../server/routes';
require('dotenv').config();
const app = express();
const io = require('socket.io')(3001);
app.use(cors({
preflightContinue: true,
methods: 'GET,PUT,POST,DELETE',
origin: '*',
}));
/**
* Using Redis adapter for multiple engine chat
*/
const redisAdapter = require('socket.io-redis');
io.adapter(redisAdapter({ host: 'redis-adapter', port: 6379 }));
// Config
app.use(bodyParser.urlencoded({ extended: false }));
app.use((req, res, next) => {
req.io = io;
next();
});
app.get('/', (req, res) => {
res.sendFile(`${__dirname}/index.html`);
});
/*
Socket.io Setting
* /
io.on('connection', (socket) => {
console.log('a user connected');
socket.on('disconnect', () => {
console.log('user disconnected');
});
socket.on('chat message', (msg) => {
console.log(`message: ${msg}`);
io.emit('chat message', msg);
});
});
export default app;
感谢您的来访,任何帮助和建议都会非常有用
暂无答案!
目前还没有任何答案,快来回答吧!