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

Still getting Continual Transport Close every PingInterval | Redis Adapter #4333

Closed
aaronkchsu opened this issue Apr 5, 2022 · 5 comments
Closed

Comments

@aaronkchsu
Copy link

aaronkchsu commented Apr 5, 2022

Describe the bug
A clear and concise description of what the bug is.

I know there is another thread on this #3025, but I read through and tried everything and still can't fix this problem, I have loved this package so far but can't seem to get this right!

I have a lot of clients connecting around 7k cc okay but I get a few clients reporting they are having disconnect issues. Looking deeper it shows that on the server they are reconnecting and disconnecting every 25 seconds (see logs below)

My pingInterval is 25000
My pingTimeout is 65000

"@socket.io/redis-adapter": "^7.1.0",
"socket.io": "4.4.1",

I'm using Amazon's ALB to 4 targets with redis adapter with a 1-minute timeout and sticky session enabled 100 seconds

Server Code

const { createClient } = require("redis");
const { createAdapter } = require("@socket.io/redis-adapter");
const pubClient = createClient({ url: process.env.REDIS_URI });
const subClient = pubClient.duplicate();

const io = new Server(server, {
    // transports: ["websocket"], // https://socket.io/docs/v4/using-multiple-nodes/
    allowEIO3: true, // false by default
    pingInterval: 25000,
    pingTimeout: 65000,

    cors: {
        origin: "*",
        methods: [
            "GET",
            "POST",
            "OPTIONS",
            "HEAD",
            "PUT",
            "PATCH",
            "POST",
            "DELETE",
        ],
    },
});


Promise.all([pubClient.connect(), subClient.connect()]).then(() => {
    io.adapter(createAdapter(pubClient, subClient));
    console.log("CONNECTED");
    // io.listen(3001); this happens with hapi above
});

Client code (disabled polling and enabled both didn't work)

    <script src="/socket.io/socket.io.js"></script>
           let socket = io({
          query: {
            roomId: last_part
          },
          transports: ['websocket'],
        });

Bugged behavior server logs, you can see it's getting a transport close every 25000
image

@aaronkchsu aaronkchsu added the to triage Waiting to be triaged by a member of the team label Apr 5, 2022
@aaronkchsu
Copy link
Author

Sorry @darrachequesne i am reposting this one #4298 to better describe the situation. We can close it and continue discussion here if it helps!

@aaronkchsu
Copy link
Author

Also have the client HAR and server logs if it helps

@darrachequesne
Copy link
Member

@aaronkchsu Could it be possible that some of the client still have a Socket.IO v2 client? That would explain the disconnection on the first ping (the client send a PING packet after 25000 seconds, but the server is supposed to send PING and receive PONG in v3/v4).

See also: https://socket.io/docs/v4/troubleshooting-connection-issues/#the-client-is-not-compatible-with-the-version-of-the-server-1

@darrachequesne darrachequesne added needs investigation and removed to triage Waiting to be triaged by a member of the team labels Apr 6, 2022
@johnfilo-kmart
Copy link

I have a similar problem with a flask-socketio server app hosted behind an aws alb and the client socket session seems to be consistently disconnecting every 26 seconds.

Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/eventlet/wsgi.py", line 573, in handle_one_response
result = self.application(self.environ, start_response)
File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2464, in call
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.8/site-packages/flask_socketio/init.py", line 45, in call
return super(_SocketIOMiddleware, self).call(environ,
File "/usr/local/lib/python3.8/site-packages/engineio/middleware.py", line 60, in call
return self.engineio_app.handle_request(environ, start_response)
File "/usr/local/lib/python3.8/site-packages/socketio/server.py", line 560, in handle_request
return self.eio.handle_request(environ, start_response)
File "/usr/local/lib/python3.8/site-packages/engineio/server.py", line 374, in handle_request
socket = self._get_socket(sid)
File "/usr/local/lib/python3.8/site-packages/engineio/server.py", line 565, in _get_socket
raise KeyError('Session is disconnected')
KeyError: 'Session is disconnected'

Client requests use /socket.io/?EIO=3&transport=polling&t=O9hzOSn&sid=xxxx

Server version of SocketIO is 4.6.0

@darrachequesne
Copy link
Member

Closed in favor of #4298.

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

No branches or pull requests

3 participants