Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AUTH command have been sent too many times #558

Open
zhangkai803 opened this issue Mar 19, 2025 · 1 comment
Open

AUTH command have been sent too many times #558

zhangkai803 opened this issue Mar 19, 2025 · 1 comment

Comments

@zhangkai803
Copy link

The cpu load of my redis server recently reached 81%. After investigation, I found that the qps of the publish command and the auth command is highly coincident. I suspect that my redis connection is not reused. So how can i reuse redis connection in my socket.io application? And could it be something else?

Image

@zhangkai803
Copy link
Author

zhangkai803 commented Mar 19, 2025

My application code:

const MyRedisConfig = {host: "127.0.0.1", port: "6379", password: "MyPassword"}
const app = require('express')();
const server = require('http').Server(app);
const io = require('socket.io')(server, {perMessageDeflate: false});
const adapter = require('socket.io-redis');
const redis = require('redis');

const myRedis = redis.createClient(MyRedisConfig);
myRedis.auth(MyRedisConfig.password);

const myAdapter = adapter({pubClient: myRedis, subClient: myRedis});
io.adapter(myAdapter);
io.engine.pingTimeout = 30000

io.on(
    'connection',
    function (socket) {
    socket.on('chat', function (msg) {
        console.log(`[${socket.id}] chat ${msg}`)
    })
})

const port = process.env.PORT || 8600;
const host = process.env.HOST || '127.0.0.1'
server.listen(port, host);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant