feat(windows-rdp): add RDP keep-alive to extend workspace deadline#710
Closed
buildingvibes wants to merge 1 commit intocoder:mainfrom
Closed
feat(windows-rdp): add RDP keep-alive to extend workspace deadline#710buildingvibes wants to merge 1 commit intocoder:mainfrom
buildingvibes wants to merge 1 commit intocoder:mainfrom
Conversation
Add opt-in keepalive feature that monitors port 3389 for established
RDP connections and calls the Coder workspace extend API to prevent
autostop during active remote desktop sessions.
The keepalive script runs as a background coder_script that:
- Uses Get-NetTCPConnection to detect active RDP connections
- Calls PUT /api/v2/workspaces/{id}/extend with CODER_AGENT_TOKEN
- Checks at a configurable interval (default 30s)
- Only reports activity when connections are present
New variables: keepalive (bool, default false), keepalive_interval
(number, default 30). Backward compatible - no changes when disabled.
Closes coder#200
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/claim #200
Summary
Adds an opt-in
keepalivefeature to the existingwindows-rdpmodule that prevents workspace autostop during active RDP sessions.How it works
When
keepalive = true, a background PowerShell script (coder_script) runs on workspace start that:keepalive_intervalseconds (default: 30) usingGet-NetTCPConnection -LocalPort 3389 -State EstablishedPUT /api/v2/workspaces/{workspace_id}/extendusing theCODER_AGENT_TOKENthat the Coder agent sets automaticallyThis uses the manual activity bump API recommended by @matifali in #200 (comment).
Why this approach
CODER_AGENT_TOKENrather than relying on stdout/stderr,coder stat, or registry keys (which only keep the TCP connection alive but don't tell Coder the workspace is active)keepalive = truefalse, no behavior change for existing userscoder_scriptresource, two new variablesUsage
Changes
main.tf: Addedkeepalive(bool) andkeepalive_interval(number) variables, conditionaldata.coder_workspacedata source, andcoder_script.windows-rdp-keepaliveresourcerdp-keepalive.ps1.tftpl: PowerShell script that monitors port 3389 and calls the extend APImain.tftest.hcl: Terraform plan tests for the new feature (and base module)main.test.ts: TypeScript tests verifying keepalive script creation and contentREADME.md: Version bump to 1.4.0, added keep-alive usage exampleTest plan
terraform test -verbosepasses in the module directorybun test main.test.tspasses (keepalive script creation, content validation, interval customization)keepalive = trueon a Windows workspace, connect via RDP, verify workspace deadline extends in Coder dashboard