I am building a web client that can RDP into remote VMs. I am running a guacd server locally (on my macbook) using docker.
I am using a JS script in the frontend to connect to a Java backend using WebSockets, which in turn creates a tunnel to the guacd server This is the standard Guacamole Web Client flow from what I have read.
These are the configurations I use when connecting to the guacd server. This is java code:
- guacConfig.setParameter("ignore-cert", "true");
- guacConfig.setParameter("force-lossless", "true");
try {
GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
new InetGuacamoleSocket(hostname, port),
guacConfig
);
GuacamoleTunnel tunnel = new SimpleGuacamoleTunnel(socket);
return tunnel;
} catch (Exception e) {
System.out.println(e);
return null;
}
This is the JS script in the index.html that uses Web sockets to connect to Java tomcat:
<script type="text/javascript"> /* <![CDATA[ */
// Get display div from document
var display = document.getElementById("display");
// Instantiate client, using an HTTP tunnel for communications.
let guacTunnel = new Guacamole.WebSocketTunnel("websocketendpoint");
var guac = new Guacamole.Client(
guacTunnel
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function(error) {
alert(error);
console.log(error)
};
// Connect
guac.connect();
// Disconnect on close
window.onunload = function() {
console.log("disconnecting");
guac.disconnect();
}
// Mouse
var mouse = new Guacamole.Mouse(guac.getDisplay().getElement());
mouse.onEach(['mousedown', 'mouseup', 'mousemove'], function sendMouseEvent(e) {
guac.sendMouseState(e.state);
});
// Keyboard
var keyboard = new Guacamole.Keyboard(document);
keyboard.onkeydown = function (keysym) {
guac.sendKeyEvent(1, keysym);
};
keyboard.onkeyup = function (keysym) {
guac.sendKeyEvent(0, keysym);
};
/* ]]> */ </script>
I run the following commands in the remote VM to start xrdp:
sudo apt-get update
sudo apt update
sudo ufw enable
sudo ufw allow ssh
sudo ufw allow 3389/tcp
sudo ufw reload
sudo systemctl stop apparmor
sudo apt install xfce4 xfce4-goodies -y
sudo apt install xrdp -y
sudo adduser xrdp ssl-cert
sudo chmod +x /etc/xrdp/key.pem
sudo reboot
I make the following configuration changes to the xrdp.ini file:
tcp_send_buffer_bytes=8388608
crypt_=none
I also change the value of the net.core.wmem_max to allow more traffic to passthrough to the network:
sudo sysctl -w net.core.wmem_max=8388608
And I stop composting. I read that this makes it run faster.
xfconf-query --channel=xfwm4 --property=/general/use_compositing --type=bool --set=false --create
When I rdp into the VM using my web client, it runs quite slowly. If I rdp using the Microsoft Remote Desktop, it runs quite smoothly. Here are two videos comparing them. The first one is from the Microsoft Remote Desktop client where I play a YouTube video and the second is from my web application.
Viewed from Microsoft Remote Desktop: https://youtu.be/hOW1wsfSVu4
My application (from the web client) https://youtu.be/5UiMNv9WSDc
This is the journalctl log for xrdp when connecting over the Microsoft client:
connected client computer name: Prabuddhas-Lapt
784]: (5784)(140716040189760)[INFO ] adding channel item name rdpdr chan_id 1004 flags 0x80800000
784]: (5784)(140716040189760)[INFO ] adding channel item name rdpsnd chan_id 1005 flags 0xc0000000
784]: (5784)(140716040189760)[INFO ] adding channel item name cliprdr chan_id 1006 flags 0xc0a00000
784]: (5784)(140716040189760)[INFO ] adding channel item name drdynvc chan_id 1007 flags 0xc0800000
784]: (5784)(140716040189760)[INFO ] TLS connection established from ::ffff:73.70.63.162 port 57150: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384
784]: (5784)(140716040189760)[DEBUG] xrdp_00001698_wm_login_mode_event_00000001
784]: (5784)(140716040189760)[INFO ] Loading keymap file /etc/xrdp/km-00000409.ini
784]: (5784)(140716040189760)[WARN ] local keymap file for 0x00000409 found and doesn't match built in keymap, using local keymap file
784]: (5784)(140716040189760)[DEBUG] xrdp_wm_log_msg: connecting to sesman ip 127.0.0.1 port 3350
784]: (5784)(140716040189760)[INFO ] xrdp_wm_log_msg: sesman connect ok
784]: (5784)(140716040189760)[DEBUG] xrdp_wm_log_msg: sending login info to session manager, please wait...
784]: (5784)(140716040189760)[DEBUG] return value from xrdp_mm_connect 0
784]: (5784)(140716040189760)[INFO ] xrdp_wm_log_msg: login successful for display 10
784]: (5784)(140716040189760)[DEBUG] xrdp_wm_log_msg: started connecting
784]: (5784)(140716040189760)[INFO ] lib_mod_log_peer: xrdp_pid=5784 connected to X11rdp_pid=1918 X11rdp_uid=1000 X11rdp_gid=1000 client_ip=::ff>
784]: (5784)(140716040189760)[DEBUG] xrdp_wm_log_msg: connected ok
784]: (5784)(140716040189760)[DEBUG] xrdp_mm_connect_chansrv: chansrv connect successful
784]: (5784)(140716040189760)[DEBUG] Closed socket 18 (AF_INET6 ::1 port 47132)
784]: (5784)(140716040189760)[DEBUG] Closed socket 12 (AF_INET6 ::ffff:192.168.122.234 port 3389)
784]: (5784)(140716040189760)[DEBUG] xrdp_mm_module_cleanup
784]: (5784)(140716040189760)[DEBUG] Closed socket 19 (AF_UNIX)
784]: (5784)(140716040189760)[DEBUG] Closed socket 20 (AF_UNIX)
This is the journalctl log when connecting from my guacamole application:
connected client computer name: Guacamole RDP
993]: (6993)(140716040189760)[INFO ] adding channel item name cliprdr chan_id 1004 flags 0xc0a00000
993]: (6993)(140716040189760)[INFO ] adding channel item name rdpdr chan_id 1005 flags 0xc0800000
993]: (6993)(140716040189760)[INFO ] adding channel item name rdpsnd chan_id 1006 flags 0xc0000000
993]: (6993)(140716040189760)[INFO ] TLS connection established from ::ffff:73.70.63.162 port 57206: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384
993]: (6993)(140716040189760)[DEBUG] xrdp_00001b51_wm_login_mode_event_00000001
993]: (6993)(140716040189760)[INFO ] Loading keymap file /etc/xrdp/km-00000409.ini
993]: (6993)(140716040189760)[WARN ] local keymap file for 0x00000409 found and doesn't match built in keymap, using local keymap file
993]: (6993)(140716040189760)[DEBUG] xrdp_wm_log_msg: connecting to sesman ip 127.0.0.1 port 3350
993]: (6993)(140716040189760)[INFO ] xrdp_wm_log_msg: sesman connect ok
993]: (6993)(140716040189760)[DEBUG] xrdp_wm_log_msg: sending login info to session manager, please wait...
993]: (6993)(140716040189760)[DEBUG] return value from xrdp_mm_connect 0
993]: (6993)(140716040189760)[INFO ] xrdp_wm_log_msg: login successful for display 10
993]: (6993)(140716040189760)[DEBUG] xrdp_wm_log_msg: started connecting
993]: (6993)(140716040189760)[INFO ] lib_mod_log_peer: xrdp_pid=6993 connected to X11rdp_pid=1918 X11rdp_uid=1000 X11rdp_gid=1000 client_ip=::ff>
993]: (6993)(140716040189760)[DEBUG] xrdp_wm_log_msg: connected ok
993]: (6993)(140716040189760)[DEBUG] xrdp_mm_connect_chansrv: chansrv connect successful
993]: (6993)(140716040189760)[DEBUG] Closed socket 18 (AF_INET6 ::1 port 42942)
993]: (6993)(140716040189760)[DEBUG] Closed socket 12 (AF_INET6 ::ffff:192.168.122.234 port 3389)
993]: (6993)(140716040189760)[DEBUG] xrdp_mm_module_cleanup
993]: (6993)(140716040189760)[DEBUG] Closed socket 19 (AF_UNIX)
993]: (6993)(140716040189760)[DEBUG] Closed socket 20 (AF_UNIX)
I have tried a bunch of things over the last week but none of them have produced the high quality output that I am expecting. Also, VNC runs much faster than RDP for some reason. But I heard it takes a lot of bandwidth away. What is the comparison like?
How can I rdp faster from my application. What would help me debug things faster???