Webconsole on another webserver with xtermjs

anzure

New Member
Jul 26, 2021
4
0
1
25
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?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!