Which service/process deems when to kill an ongoing AppStream session?


In some earlier answers, I've been told that there's an AppStream Agent running during the session. But I cannot find it in the Windows Task Manager. I've found PhotonWindowsCustomShell, PhotonAgent, and some other SSM and CloudWatch agents.

  1. Which process evaluates if the session reached Disconnect or Idle Timeout?
  2. Is there a way to communicate with that process and hinder it from killing the instance if our app is above a certain CPU utilization threshold?
asked 10 days ago42 views
3 Answers

You could try, if you can emulate keyboard or mouse movement to keep the session active. You can register a powershell script to be called regularly (maybe once every 10 minutes) and move the mouse by 1 point.

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)

This could be done conditionally (on high CPU-load only). That should not interfere with the user too much.

Get-WmiObject Win32_Processor | Measure-Object -Property LoadPercentage -Average | Select Average

However, I am not sure, if that approach to programmatically move the mouse keeps the session alive. That would need to be tested.

answered 10 days ago
  • Yes, we've tried that. We have a PowerShell script running and evaluating CPU utilization and when thresholds are breached we've tried both with keyboard input ($WShell.sendkeys()) and mouse movement (New-Object System.Drawing.Point()) but it's not working. We're evaluating the Idle state from Win32 API GetLastInputInfo. Any idea why Photon Agent doesn't pick up those inputs?

  • What is your use case? Is changing the timeout value to higher number not an option as mentioned in our documentation suggested by StevieStets below.

  • Okay, then one more idea. It appears, you can prevent appstream from disconnecting idle users. Quote from CLI command here: https://docs.aws.amazon.com/cli/latest/reference/appstream/create-fleet.html: --idle-disconnect-timeout-in-seconds: To prevent users from being disconnected due to inactivity, specify a value of 0. Otherwise, specify a value between 60 and 3600. The default value is 0.

    Then what you could do is disable that automatic idle disconnect handling. You can then - if you need to - find some other way of deactivating an ongoing session. We are for instance using expire-session to kick out users, where their "prepaid usage-amount" has been completely consumed (this is some value managed by us). We have a shell script via cron within each client, which checks that usage amount and in case this falls below zero, this script calls expire-session for the current client (that's Linux, but it should also work in Windows clients).

  • Our client will have basically two types of users: 1st working 8-10 hours a day, 2nd uses instances for long-term calculations that can take more than 12 hours (often longer, no user activity). Our client doesn't want to differentiate customers and create an additional fleet because we already have two different stream.graphics-design fleets. So disabling Idle and setting up the Disconnect timeouts for say 18 hours will lead to unutilized resources among the first group of users. That's why we're looking for a solution that would hinder the session termination based on actual CPU usage.


I would not recommend trying to change the behavior of the session timers beyond what is documented. https://docs.aws.amazon.com/appstream2/latest/developerguide/set-up-stacks-fleets.html#set-up-stacks-fleets-create

answered 10 days ago


Photon Agent is responsible for communicating the session state to the backend service. You can't interfere or communicate with the process to extend the session.

The session is considered active only if there is keyboard and mouse interaction, otherwise the session is considered idle and idle timeout will trigger. CPU utilization on instance isn't considered active session. Once the idle timeout value expires, the session is disconnected. Next, the backend service evaluates the "Disconnect Timeout", if it has expired the session is terminated.

answered 10 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions