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

fix: close old websocket before every connection attempt #6937

Merged
merged 1 commit into from
Mar 18, 2022

Conversation

Saschl
Copy link
Contributor

@Saschl Saschl commented Mar 18, 2022

Fixes #[issue_no]

Summary of Changes

If a Websocket fails to connect it doesn't seem to close but stays open (visible in the debugger and in ram usage). If the MCDU Server is not used this leaks a Websocket connection every attempt. This slowly fills up the RAM and lead to increased CPU usage.

I removed the "readyState" condition on a reconnect so the old socket is closed and properly garbage collected.

Screenshots (if necessary)

Before:
Lots of sockets...
image

After:
image
Just one WebSocket that also reports closed.

References

Additional context

Discord username (if different from GitHub):

Testing instructions

How to download the PR for QA

Every new commit to this PR will cause a new A32NX artifact to be created, built, and uploaded.

  1. Make sure you are signed in to GitHub
  2. Click on the Checks tab on the PR
  3. On the left side, click on the bottom PR tab
  4. Click on the A32NX download link at the bottom of the page

If a websocket fails to connect it doesn't seem to close but stays open (visible in the debugger and in ram usage). If the MCDU Server is not used this leaks a Websocket connection every attempt.
@Saschl
Copy link
Contributor Author

Saschl commented Mar 18, 2022

Merging this as it's been approved and a trivial fix that doesn't change the behaviour and functionality of the feature.

@Saschl Saschl merged commit 774dbcb into flybywiresim:master Mar 18, 2022
@Saschl Saschl deleted the fix/websocket-leak branch March 18, 2022 16:40
Saschl added a commit to Saschl/a32nx that referenced this pull request Mar 20, 2022
Benjozork pushed a commit that referenced this pull request Mar 20, 2022
* Revert "fix: close old websocket before every connection attempt (#6937)"

This reverts commit 774dbcb.

* chore: decrease check connection interval
ErickSharp pushed a commit that referenced this pull request Apr 3, 2022
If a websocket fails to connect it doesn't seem to close but stays open (visible in the debugger and in ram usage). If the MCDU Server is not used this leaks a Websocket connection every attempt.
ErickSharp pushed a commit that referenced this pull request Apr 3, 2022
* Revert "fix: close old websocket before every connection attempt (#6937)"

This reverts commit 774dbcb.

* chore: decrease check connection interval
@2hwk 2hwk added this to the v0.8.0 milestone Apr 29, 2022
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

Successfully merging this pull request may close these issues.

3 participants