Linux Workspot VDI Disconnects Immediately on Reconnect

Prev Next

If a user on a Linux Workspot VDI authenticates successfully but is disconnected immediately, an orphaned XRDP session is the likely cause. To recover, reboot the VM or terminate the stale user session. To prevent recurrence, apply the recommended XRDP session settings described in this article.

Overview

Users may intermittently fail to reconnect to a Linux Workspot VDI. Authentication succeeds, but the session disconnects immediately after the connection is established.

This behaviour occurs when an orphaned XRDP session remains active on the virtual desktop and the XRDP session manager (xrdp-sesman) loses track of that session after a service restart.

This article explains the symptoms, cause, recommended configuration, and remediation steps.

Symptoms

Affected users may observe one or more of the following:

  • Connection initiates successfully but disconnects immediately.

  • Repeated connect/disconnect loops.

  • Desktop reconnect attempts continue to fail.

  • No obvious authentication failures are observed.

  • Workspot Control and Gateway logs indicate successful authorization.

  • Linux VM remains powered on and healthy.

In these cases, authentication and gateway authorization complete successfully, but the desktop session cannot be established because an orphaned XRDP session blocks normal session creation (see Cause).

Cause

This issue occurs when all three of the following conditions are present, in this order:

1. XRDP Sessions Are Allowed to Persist Indefinitely

When XRDP is configured without a disconnected-session time limit:

  • Disconnected sessions are not automatically terminated.

  • Sessions can remain active indefinitely.

2. XRDP Services Restart

Linux operating system updates or maintenance operations may restart:

  • xrdp

  • xrdp-sesman

When the XRDP session manager restarts, it loses its in-memory session tracking information. Existing user sessions may continue running, but the session manager no longer recognizes them, which leaves them orphaned.

3. Orphaned Session Remains Active

If a disconnected session remains running after the service restart, future login attempts may result in:

  • Creation of a new session.

  • Session conflicts.

  • Immediate termination of the newly created session.

  • Continuous reconnect failures.

How to Identify the Issue

Review active XRDP and Xorg processes:

Command:

ps aux | grep -i xrdp

ps aux | grep -i Xorg

Example output:

username 390215 Sep11 /usr/lib/xorg/Xorg :10

username 390248 Sep11 /usr/sbin/xrdp-chansrv

In the output, the first column shows the user who owns the process and the date column shows when it started. If an Xorg or xrdp-chansrv process for a user started days earlier and is still running while that user cannot connect, it is likely an orphaned XRDP session.

Immediate Resolution

Option 1: Reboot the VM

Rebooting the VM also clears the stale user session.

Option 2: Terminate the stale user session

Alternatively, terminate only the stale user session without rebooting the VM. Replace username with the affected user's Linux account name. This ends all processes owned by that user.

Example command:

pkill -u username

After removing the orphaned session, the user should be able to establish a new XRDP session normally.

Recommended Configuration

To reduce the likelihood of stale session accumulation, update the XRDP session management configuration.

Recommended Settings

MaxSessions=2

KillDisconnected=true

DisconnectedTimeLimit=7200

Where:

Setting

Value

Description

MaxSessions

2

Allows recovery if one user session becomes stale

KillDisconnected

true

Automatically removes disconnected sessions

DisconnectedTimeLimit

7200

Terminates disconnected sessions after 2 hours

These settings help prevent orphaned sessions from accumulating and improve recovery after XRDP service restarts.

Note: DisconnectedTimeLimit is set in seconds (7200 seconds = 2 hours) and can be adjusted to meet your requirements.

Updating the XRDP Configuration

Step 1: Back up the configuration file

Before you make changes, back up the existing configuration so you can restore it if needed:

sudo cp /etc/xrdp/sesman.ini /etc/xrdp/sesman.ini.bak

Step 2: Open the configuration file

Modify the following file:

/etc/xrdp/sesman.ini

Step 3: Apply the settings

sudo sed -i 's/^MaxSessions=.*/MaxSessions=2/' /etc/xrdp/sesman.ini

sudo sed -i 's/^KillDisconnected=.*/KillDisconnected=true/' /etc/xrdp/sesman.ini

sudo sed -i 's/^DisconnectedTimeLimit=.*/DisconnectedTimeLimit=7200/' /etc/xrdp/sesman.ini

Step 4: Verify the settings

grep -E '^(MaxSessions|KillDisconnected|DisconnectedTimeLimit)=' /etc/xrdp/sesman.ini

Expected output:

MaxSessions=2

KillDisconnected=true

DisconnectedTimeLimit=7200

Step 5: Apply the changes

A VM reboot is sufficient to apply the updated settings.

Important: Rebooting the VM disconnects all active sessions. Confirm that no users are connected, or schedule the reboot for a maintenance window, before you run the command below.

sudo reboot

Best Practices

  • Avoid keeping disconnected sessions indefinitely.

  • Configure automatic disconnected-session cleanup.

  • Review XRDP session policies during Linux template creation.