Webconsole on another webserver with xtermjs

anzure

New Member
Jul 26, 2021
4
0
1
26
I am attempting to host a xtermjs terminal on another webserver.
When using xtermjs library and javascript websocket the connection fails.

JavaScript:
import { Terminal } from 'xterm';
import { AttachAddon } from 'xterm-addon-attach';

const user = "root@pam";
const ticket = "PVEVNC:6116D801::H8a......V6egwpEFg==";
const term = new Terminal();
const socket = new WebSocket(
  "wss://x.x.x.x:8006/api2/json/nodes/srv1/qemu/101/vncwebsocket?port=5900&vncticket=" +
    encodeURIComponent(ticket),
  "binary"
);
socket.onopen = function (e) {
  socket.send(user + ":" + ticket + "\n");
};
const attachAddon = new AttachAddon(socket);

term.loadAddon(attachAddon);

I have attempted a lot of different combinations than mentioned above.
Every time I get the "WebSocket connection to ............. failed" error.

The firewall seems to be off, so I do not think that is the problem.

However, xtermjs works perfectly fine inside Proxmox itself.
I have tried to find a solution for multiple days now, but I'm stuck.
Do anyone here have a suggestion for what may cause this problem?