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

Error "Tried changing state of a disconnected RFB object" on automatic reconnection #56

Open
3 tasks done
marc-legendre opened this issue Jun 26, 2024 · 1 comment
Open
3 tasks done
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@marc-legendre
Copy link

Are you certain it's a bug?

  • Yes, it looks like a bug

Are you sure this is not an issue in noVNC?

  • It is not a noVNC issue

Is there an existing issue for this?

  • I have searched existing issues, it hasn't been reported yet

Issue description

Hi there, I'm trying out this nice little project, and I noticed a small issue.

noVNC emits an error "Tried changing state of a disconnected RFB object" when VncScreen automatically tries to reconnect after a connection loss.

Details

It is an error to call rfb.disconnect() once rfb is in a disconnected state.

This happens when losing the connection to the server. Indeed, a call to connect() is scheduled without clearing rfb or connected. Then when connect() is called, it calls disconnect(), which calls rfb.disconnect().

Note: noVNC emits an error, but handles the situation gracefully.

Clearing rfb prevents this from happening:

diff --git i/src/lib/VncScreen.tsx w/src/lib/VncScreen.tsx
index af032d9..e73d3c9 100644
--- i/src/lib/VncScreen.tsx
+++ w/src/lib/VncScreen.tsx
@@ -160,6 +160,7 @@ const VncScreen: React.ForwardRefRenderFunction<VncScreenHandle, Props> = (props
         if (connected) {
             logger.info(`Unexpectedly disconnected from remote VNC, retrying in ${retryDuration / 1000} seconds.`);
 
+            setRfb(null);
             timeouts.current.push(setTimeout(connect, retryDuration));
         } else {
             logger.info(`Disconnected from remote VNC.`);

Intuitively, I'd also clear connected. But I am not entirely sure if I get connected right, since it is initialized to true when autoconnect is enabled. I find this puzzling 🤔

@roerohan
Copy link
Owner

Hi @marc-legendre , thanks for reporting the issue. I somewhat understand what the issue is, but I can't think of how to fix it off the top of my head. I'll try to take a look at this during the weekend, in the meantime if you want to raise a PR for the fix please feel free to do so!

@roerohan roerohan added bug Something isn't working help wanted Extra attention is needed labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants