The noVNC console can be used from your own panel or tooling. Connect to the WebSocket endpoint on port 443:
wss://provider.example.invalid/websockify
Authenticate the connection
Send a JSON object as the first message. It must contain the token and service ID:
{"token": "YOUR-TOKEN", "serviceid": "YOUR-SERVICE-ID"}
API keys and session tokens are supported. A sub-user also needs the noVNC console permission. The message must be valid JSON and use double quotes.
The server closes the connection after either of these errors:
Error 1: the JSON is invalidError 2: the token is invalid or does not have access to the service
Start the VNC session
After authentication, the server sends one text frame containing a temporary VNC password that starts with PVEVNC. The rest of the connection is a normal binary VNC-over-WebSocket stream using the RFB protocol.
Use the temporary password during the VNC handshake and leave the username blank. Do not pass the password frame to the VNC client as part of the VNC stream. Each connection gets a new password, so reconnecting requires a new authentication message.
noVNC 1.3 or later example
Stock noVNC does not send the authentication message for you. From version 1.3, you can pass an open WebSocket to the RFB constructor:
import RFB from './core/rfb.js';
const ws = new WebSocket('wss://provider.example.invalid/websockify', ['binary']);
ws.addEventListener('open', () => {
ws.send(JSON.stringify({ token: 'YOUR-TOKEN', serviceid: 'YOUR-SERVICE-ID' }));
});
ws.addEventListener('message', function onAuth(e) {
if (typeof e.data === 'string' && e.data.startsWith('PVEVNC')) {
ws.removeEventListener('message', onAuth);
new RFB(document.getElementById('screen'), ws, {
credentials: { username: '', password: e.data }
});
} else if (typeof e.data === 'string' && e.data.startsWith('Error')) {
console.error('Authentication failed: ' + e.data);
}
});
The endpoint allows up to 30 connection attempts per minute for each service.