vnc.js: how to build a JavaScript VNC Client in a 24 hour hackday

LinkedIn Engineering Team
6 min readintermediate
--
View Original

Overview

The article discusses the development of a JavaScript VNC client, vnc.js, created during a 24-hour hackday at LinkedIn. It covers the architecture, implementation of the RFB protocol, and the technologies used to achieve a fully functional VNC client running in a web browser.

What You'll Learn

1

How to build a VNC client using JavaScript and Node.js

2

Why using socket.io is essential for real-time communication in web applications

3

How to implement the RFB protocol for remote desktop access

Prerequisites & Requirements

  • Understanding of the RFB protocol and VNC concepts
  • Familiarity with Node.js and socket.io
  • Basic JavaScript programming skills

Key Questions Answered

What technologies are used to build the vnc.js client?
The vnc.js client is built using JavaScript, Node.js, socket.io, and HTML5 canvas. These technologies enable the client to connect to remote VNC servers and render the desktop in a web browser.
How does the RFB protocol work in the context of vnc.js?
The RFB protocol is implemented in a subset that includes authentication, ServerInit, continuous frame buffer updates, and mouse/keyboard support. This allows for efficient communication and rendering of remote desktops in the browser.
What challenges were faced during the implementation of the VNC client?
Challenges included correctly implementing the RFB protocol, particularly the authentication phase and handling multiple updates in a single message. These issues were resolved by referencing existing open-source VNC clients and debugging the communication process.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Frontend
Javascript
Used to build the VNC client that runs in the browser.
Backend
Node.js
Serves as the proxy to connect the browser to the remote VNC host.
Backend
Socket.io
Facilitates real-time communication between the client and server.
Frontend
Html5 Canvas
Used to render the remote desktop in the browser.

Key Actionable Insights

1
Focus on building a clean abstraction for connectivity when developing web applications that require real-time communication.
Using a consistent language like JavaScript across both client and server simplifies the architecture and reduces complexity.
2
Implementing a subset of a protocol can be an effective strategy when time is limited.
By focusing on essential features of the RFB protocol, the team was able to deliver a functional product within the hackday timeframe.
3
Utilize existing open-source resources to troubleshoot and enhance your project.
Referencing open-source VNC clients helped the team understand the nuances of the RFB protocol, leading to successful implementation.

Common Pitfalls

1
Failing to correctly implement the authentication phase of the RFB protocol can lead to connection issues.
This can happen due to overlooked details in the protocol specification, such as padding and bit manipulation, which are crucial for successful authentication.