Failed when connecting: Connection closed (code: 1005)
khaledayed opened this issue · comments
I used @novnc/novnc": "^1.4.0
and websockify v0.8.0
in an Angular app v14, i ran the command:
npm run websockify localhost:6080 localhost:5901
In app.component.ts i have added this:
import { Component } from "@angular/core";
import RFB from "../../node_modules/@novnc/novnc/core/rfb.js";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent {
title = "vnc-client";
public rfb: RFB;
startClient() {
console.log("Starting !!!");
const host = window.location.hostname;
const port = "6080";
const password = "foobar"; // password of your vnc server
const path = "websockify";
// Build the websocket URL used to connect
let url = "ws";
if (window.location.protocol === "https:") {
url = "wss";
} else {
url = "ws";
}
url += "://" + host;
if (port) {
url += ":" + port;
}
url += "/" + path;
console.log("URL: ", url);
// Creating a new RFB object will start a new connection
this.rfb = new RFB(document.getElementById("screen"), url, {
credentials: { password: password },
});
}
}
but i have these errors in console:
rfb.js:941 Failed when connecting: Connection closed (code: 1005)
And
rfb.js:941 Failed when connecting: Connection closed (code: 1006)
Could you share the entire console? There should hopefully be some more details from the browser.
And what does websockify say when this happens?
I see that you've also posted to the mailing list. So let's continue there so we don't have duplicate discussions.