noVnc connection error: Failed when connecting: Connection closed (code: 1005) #560

202 views
Skip to first unread message

Khaled ayéd

unread,
Aug 7, 2023, 5:00:12 AM8/7/23
to noVNC
Hello everyone,
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 !!!");

    // Read parameters specified in the URL query string
    // By default, use the host and port of server that served this file
    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 this  error in console:
```rfb.js:941 Failed when connecting: Connection closed (code: 1005)```

宋超

unread,
Aug 10, 2023, 7:48:02 AM8/10/23
to noVNC
Has the VNC image started? 1005 means you are not connected to the vnc image.
Reply all
Reply to author
Forward
0 new messages