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

Websocket Connection Becomes Unstable - Starts disconnecting and reconnecting after a while of being active #1603

Open
yakirs57 opened this issue Dec 29, 2023 · 3 comments
Labels
needs investigation This issue needs further investigations

Comments

@yakirs57
Copy link

Description
I am using a Python based Websocket server version 5.4.1 and a React JS based Websocket client version 4.3.2.
My application is connecting to 10 Websocket servers from 1 client.
For some of my clients, after a random duration of time, the websocket connection starts to become unstable, disconnect and then reconnect nonstop.

To Reproduce
It doesn't reproduce by doing a certain action.
Even when there is a network disconnection we manage to reconnect without a problem and maintain a stable connection.
But it still seems like in certain situations, when the network speed is slow, and it experienced a disconnection of some sort, this happens. Although it doesn't happen every time.
I am struggling with solving it, and figuring out exactly when and why it happens.

Socket.IO server version: 5.4.1
Socket.IO client version: 4.3.2

Server

import flask
from flask_socketio import SocketIO

app = flask.Flask(__name__)
socketio = SocketIO(app, cors_allowed_origins="*", ping_timeout=1200, ping_interval=1205, logger=False, engineio_logger=False)

Client

import {io} from "socket.io-client";

io( `${ep}/${namespace}`, { 'transports': ["websocket"], } )

Platform:
Happens on both Android and IOS devices.

@yakirs57 yakirs57 added the to triage Waiting to be triaged by a member of the team label Dec 29, 2023
@darrachequesne
Copy link
Member

Hi! What is the reason of the disconnection?

socket.on("connect_error", (err) => {
  console.log(err);
  console.log(err.context);
});

socket.on("disconnect", (reason, details) => {
  console.log(reason);
  console.log(details.context);
});

If you are using the Python implementation, did you open an issue in the repository ?

@darrachequesne darrachequesne added needs investigation This issue needs further investigations and removed to triage Waiting to be triaged by a member of the team labels Jan 5, 2024
@FabianHummel
Copy link

I have a similar issue with a rust server implementation (socketioxide) and socket.io-client. I am getting the error "got plaintext data when reconstructing a packet" in the socket.io-parser library. This is especially often the case when sending two packets in the same exact moment as the Json-Binary packet-pairs are getting mixed up and result in an invalid position like Json-Json and Binary-Binary which causes the parser to throw.

@yakirs57
Copy link
Author

@darrachequesne I am still uncertain about the reason of the disconnection. I was not aware that it can be investigated in the manner you presented in your comment.

I am using Python in the BE and Javascript in the FE. The disconnection happens from the FE side and not the BE side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation This issue needs further investigations
Projects
None yet
Development

No branches or pull requests

3 participants