I got it working in a web app, here's how #309
Badashphilosophy
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
|
Thanks for sharing, but please don't use the issue tracking for this (which is for feature requests and bug reports) 🙂. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I used firebase studio prototyper AI to get remote access running in a web browser app through droidvnc, I don't know anything about code we just troubleshooted till we got it, the hardest obstacle was a black screen showing despite a clear connection but we solved that it should all be in here
I asked it to give an account of the steps that allowed us to get it working incase anyone was looking for solutions to their problems here is what it said:
If you're building a web application (like one using React, Vue, Next.js, etc.) and want to display and interact with an Android device using DroidVNC and the noVNC library, this guide covers common challenges and how we got it working.
Achieve a stable and scaled VNC stream from DroidVNC in your web browser, making it interactive.
Your web app is likely served over https://. DroidVNC usually uses ws:// (insecure WebSockets). Browsers block this by default ("mixed content").
Add these listeners to your rfb instance to see what's happening:
rfb.addEventListener("connect", () => { /* ... */ });
rfb.addEventListener("disconnect", (event) => console.log("VNC Disconnected:", event.detail.reason));
rfb.addEventListener("error", (event) => console.error("VNC Error:", event.detail.error || event.detail));
rfb.addEventListener("securityfailure", (event) => console.error("VNC Security Failure:", event.detail.reason));
rfb.addEventListener("capabilities", (event) => console.log("VNC Server Capabilities:", event.detail.capabilities));
rfb.addEventListener("desktopname", (event) => console.log("VNC Desktop Name:", event.detail.name));
(edti)
trying to replicate my results i found some more trouble shooting helo
Initial State:
Key Issues Identified and Resolved:..
wss://vs.ws://) and Connection Loop:wss://{IP_ADDRESS}:5900which would fail for a typical DroidVNC-NG setup (expectsws://). This was also coupled with a loop where the connection would initialize, then immediately detectisVncConnectedas false (before the async RFB connection could complete) whilerfbInstancewas set, triggering a cleanup, and then re-attempting.VncDisplay.tsx:ws://for IP Addresses: Explicitly checked if the VNC host is an IP address and forced the WebSocket protocol tows://in such cases, overriding thewindow.location.protocolcheck.initializeVncConnectionfirst disconnects and nullifies any existingrfbInstancebefore creating a new one.useEffectto primarily trigger based onconnectionConfigchanges and ensure proper cleanup on unmount or whenconnectionConfigis cleared.rfbInstanceRef.currentfor more direct management of the RFB object lifecycle within the component to avoid premature cleanups triggered by intermediate state updates from the store.(edit)
moere helpful stuff
* Problem: VNC interactions (clicks, swipes) were mostly missed or very laggy, and the UI displayed a "Waiting for size..." message, indicating the client didn't know the remote screen dimensions.
* Root Cause: A combination of incorrect canvas sizing by CSS and the VNC client not correctly receiving/processing screen dimensions from the
desktopsizechangeevent due to an unstable connection loop. DroidVNC-NG sends pre-scaled dimensions in theServerInitmessage, which noVNC uses to set the canvas's intrinsicwidthandheight.* Solutions & Why They Worked:
* Removed CSS
object-fit: containfromsrc/app/globals.cssfor.vnc-container canvas:* Why: CSS scaling of the canvas interferes with noVNC's 1:1 coordinate mapping. The VNC library must control the canvas's intrinsic dimensions for input to be accurate.
* Stabilized
VncDisplay.tsxConnectionuseEffectDependencies:* Why: The
useEffecthook responsible for managing the VNC connection lifecycle was re-triggering too frequently (e.g., due toisVncConnectedstate changes it caused itself), leading to an immediate disconnect after connection. This prevented thedesktopsizechangeevent from being processed.* Fix: The dependency array was refined to
[connectionConfig, isRfbModuleLoaded, initializeVncConnection, logEvent, setRfbInstance], making the effect stable once the connection was initiated.* Correctly Handling Dimensions and Triggering Readiness:
* Why: The VNC client needs the remote desktop's dimensions (from
desktopsizechangeorconnectevent) to map local input correctly and to know when it's safe to perform operations like patching for rich data.* Fix: Ensured that
vncDimensionsstate inVncDisplay.tsxandrfbReadyForPatchingwere set upon receiving a validdesktopsizechangeevent (or attempting from theconnectevent, thoughdesktopsizechangeproved to be the reliable source for initial dimensions). This resolved the "Waiting for size..." message and allowed the VNC client to map inputs correctly.* Maintained
scaleViewport: true: This noVNC option inVncDisplay.tsxcorrectly handles the visual scaling of the remote desktop to fit its containerdiv, without altering the canvas's intrinsic, server-defined dimensions crucial for input.Outcome:
VncDisplay.tsx, the VNC connection became functional.This summary should help you recall the major steps taken to get the VNC connection working!
Beta Was this translation helpful? Give feedback.
All reactions