-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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: Prevent connection error in console log for MCDU socket connection attempts #6939
Conversation
13b0197
to
9a0fff2
Compare
if (this.socket) { | ||
this.socket.close(); | ||
this.socket = undefined; | ||
if (this.socket.readyState) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about readyState == 2 and == 3? Do we want to call socket.close when it's already CLOSING
or CLOSED
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is already the case:
if (this.socket) {
if (this.socket.readyState) {
console.log('Attempting to close socket: readyState=' + this.socket.readyState);
this.socket.close();
}
delete this.socket;
}
All non 0 will be closed.
And the call during 3 does not cause an error message as my log above shows.
This currently does not solve the issue with websockets not being closed properly. Investigation for a better solution ongoing - two alternatives:
|
Option 3, don't use websockets... with keepalive and memorising the failed status (=> only trying at longer intervals) it shouldn't be too much different. |
How to connect to the Remote MCDU Server then? |
Closing in favor of #6947 |
Plain HTTP without websockets. |
Failed fetch requests also cause lag, so that won't help. |
Big oof. 😬 |
Summary of Changes
PR #6937 tried to fix a suspected memory leak but introduced a former issue printing error messages to the console at every connection attempt of the websocket connection to the MCDU Server.
After testing and checking this fix should avoid the error message again and make sure the socket object is properly deleted.
Running this over a longer time did not reveal any memory consumption or fps loss.
Additional context
With debug code:
This is the output with MCDU Server off (the number behind DEBUG is the socket.readyState):
This is the output with MCDU turned on then off:
==> So the socket object is properly deleted. If MSFS still has it in memory and does not garbage collect it is beyond our control.
Discord username (if different from GitHub): Cdr_Maverick#6475
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.
…sages