Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect after disconnecting from RDP session #964

Closed
3 tasks done
ReenigneArcher opened this issue Feb 20, 2023 · 21 comments · Fixed by #1115
Closed
3 tasks done

Cannot connect after disconnecting from RDP session #964

ReenigneArcher opened this issue Feb 20, 2023 · 21 comments · Fixed by #1115
Assignees
Labels
fixed This issue has been fixed and will be available in the next release. os:Windows OS is Windows

Comments

@ReenigneArcher
Copy link
Member

ReenigneArcher commented Feb 20, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Is your issue described in the documentation?

  • I have read the documentation

Is your issue present in the nightly release?

  • This issue is present in the nightly release

Describe the Bug

With Sunshine running as a service, cannot connect to Sunshine from Moonlight after using the Windows built in method of disconnecting from a remote desktop session.

Can connect if using this workaround, but that leaves the system unlocked, so is not preferred. This is a batch script that must be run as admin. It is not a prep command for Sunshine.

@echo off
for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
  %windir%\System32\tscon.exe %%s /dest:console
)

Can also connect to locked desktop as before using RDP.

Expected Behavior

No response

Additional Context

No response

Host Operating System

Windows

Operating System Version

11

Architecture

64 bit

Sunshine commit or version

v0.18.3

Package

Windows - installer

GPU Type

Nvidia

GPU Model

GeForce RTX 2080 Super

GPU Driver/Mesa Version

528.49

Capture Method (Linux Only)

No response

Relevant log output

No response

@da-anda
Copy link

da-anda commented Mar 15, 2023

this is not specific to sunshine. This also is/was the case with nvidia GameStream. It's even mentioned in the Moonlight troubleshooting section that using RDP will cause this issue.

@Nonary
Copy link
Collaborator

Nonary commented Mar 15, 2023

Yeah its not necessarily related to Sunshine but we might be able to do something to fix the issue, this issue was created just so that if people searched for it they would understand that its known behavior.

Although, I can't seem to replicate this issue on my machine. It's able to connect back just fine even after using RDP, I am not entirely sure why though.

@digi-chris
Copy link

Not sure if this helps find a solution, but I have the same issue and I've found that when it happens, I can fix it by logging in using VNC. After logging in that way, it seems to clear the problem and Moonlight will work again.

I've written some test code just to figure out what's going on with RDP. I find that occasionally when logged in with RDP, if I enumerate the available monitors on the machine, I'll get a list of the actual physical displays as presented by the GPU. Generally everything works fine when this is the case. However most of the time I'll get a list of 'virtual' displays, and this seems to be when things go wrong.

Whenever the displays listed are virtual, I'll then find Moonlight won't log in when I quit the RDP session. My theory is that Windows gets locked in a state where it's 'detached' from the physical monitors, and then Sunshine can't hook into the GPU because there's no output on it.

Going to the actual machine and logging in puts things back as they were before, and now Sunshine works because the GPU is once again displaying the desktop. Likewise, logging in with VNC seems to act in the same way as being at the physical machine - so it fixes the problem.

It's just a theory but I think if somebody figured out what VNC server is doing (I'm using TigerVNC for my tests) during that initial connection, it might present a solution for Sunlight?

@ReenigneArcher
Copy link
Member Author

Logging back in with any method fixes it, even RDP if you disconnect with the script I put above.

@ReenigneArcher ReenigneArcher pinned this issue Mar 30, 2023
@RKDUDE02
Copy link

RKDUDE02 commented Apr 6, 2023

Personally, the script did not work for me at all. I'm on windows 11. But, I found something that works for me and figured I would share here.

I use rdp to login and restart my computer, then I wait for my computer to start up again and sunshine works normally again until I use rdp again, then I have to restart to use sunshine again. It's not a very elegant solution but it's better than nothing

This solutions also locks your system, unlike the script above

@ReenigneArcher
Copy link
Member Author

the script did not work for me at all

It's a batch script, you need to run it as admin while connected to the remote desktop session. This is not a prep command script for Sunshine.

@svenlange2
Copy link

I have found that if you "start -> log out" instead of just close the RDP connection from the "x", then youll be able to log back with Moonlight. Next time the Moonlight connection opens (I am using the Desktop connection) you'll be presented with login screen of Windows.

@xx1182
Copy link

xx1182 commented May 9, 2023

I have found that if you "start -> log out" instead of just close the RDP connection from the "x", then youll be able to log back with Moonlight. Next time the Moonlight connection opens (I am using the Desktop connection) you'll be presented with login screen of Windows.

This doesn't work for me, tried both clicking my username and the "shutdown icon" to disconnect. The script works.

(Android RDP)

@Eric2XU
Copy link

Eric2XU commented May 26, 2023

While true not Sunshines fault, I agree that Sunshine when getting a connection (or perhaps when failing to connect) could execute this command or perhaps a better scoped version of that calls the very same API that the tscon.exe tool does to close out any open rdp sessions.

The reason it matters to me, I have a headless Windows box JUST for gaming (I switch to a Mac after Windows 11 and what I can only describe as Microsoft clearly not caring about Windows moving forward since they make their money on cloud services now). Using Moonlight to admin the box is a pain, RDP is truly better then all other remote control (except for when gaming).

My previous workaround was to reboot as I have my box setup to auto logon but now ill make a shortcut to run tscon as admin. But again, would just be killer if baked into the tool. If people are uneasy about it, make it a non-default option. There has been enough people on the nvidia side asking about this that sunshine could make a positive impact for a decent group of people with this fairly easy shim.

Just my thoughts on it.

@ReenigneArcher
Copy link
Member Author

could execute this command or perhaps a better scoped version of that calls the very same API that the tscon.exe tool does to close out any open rdp sessions

This would be a security risk if an attacker had access to a paired moonlight client... kicking out an admin connected to RDP. RDP should take priority over any moonlight session.

Let's be real... far too many users are giving moonlight access to casual friends and family members. So we won't automatically handle this for you, but feel free to add it as a prep command (that may work).

@Nonary
Copy link
Collaborator

Nonary commented May 26, 2023

could execute this command or perhaps a better scoped version of that calls the very same API that the tscon.exe tool does to close out any open rdp sessions

This would be a security risk if an attacker had access to a paired moonlight client... kicking out an admin connected to RDP. RDP should take priority over any moonlight session.

Let's be real... far too many users are giving moonlight access to casual friends and family members. So we won't automatically handle this for you, but feel free to add it as a prep command (that may work).

Prep commands won't work because they require an active console session now, which RDP closes out when disconnecting.

@Nonary
Copy link
Collaborator

Nonary commented May 26, 2023

I would say it's pretty unlikely we would add a workaround to this problem. By design, windows won't allow us to execute processes under a users account unless they're an "active" console session.

The reason why sunshine doesn't work is because of this limitation. If you execute an application that has no command and prep commands disabled, it will let you in without issues.

By leaving the command/detached field blank and make sure it has no prep commands (including global ones) it will not matter that a user is not signed in or disconnected, you will be able to tunnel in and sign in without issues.

@cgutman
Copy link
Collaborator

cgutman commented May 26, 2023

The original bug reported here is fixed by 9955890. Sunshine will respawn on the console Winlogon session when the original user session is taken over by RDP. Logging back into an existing connection will result in a temporary disconnection as Sunshine spawns back into the original console session, but otherwise is usable now.

We can't do prep/undo commands for the reasons mentioned above.

@cgutman cgutman added the fixed This issue has been fixed and will be available in the next release. label May 26, 2023
@LizardByte-bot
Copy link
Member

This issue has been fixed and will be available in the next release.

@ReenigneArcher ReenigneArcher mentioned this issue May 29, 2023
7 tasks
@ReenigneArcher ReenigneArcher unpinned this issue May 29, 2023
@stammerjoker
Copy link

I still have this problem with Sunshine 0.21.0. It should have been fixed in v0.20.0. Anybody else?

@ReenigneArcher
Copy link
Member Author

Works for me... You still need to disconnect the rdp session.

@phuein
Copy link

phuein commented Jan 8, 2024

I still have this problem with Sunshine 0.21.0. It should have been fixed in v0.20.0. Anybody else?

I found a setting in Sunshine -> Applications that might be related:

Continue streaming if the application exits quickly

I'm using Desktop, so will try unchecking this option.

@diphuaji
Copy link

This script saved my day! You just need to store the code in a file ending with .bat and right click -> run as admin. Done

@Nonary
Copy link
Collaborator

Nonary commented May 12, 2024

This script saved my day! You just need to store the code in a file ending with .bat and right click -> run as admin. Done

You don't need a script as long as you've installed the latest version of Sunshine.

And you need to launch the Desktop app in Moonlight, to sign back in, otherwise it will fail until you sign back in

@diphuaji
Copy link

This script saved my day! You just need to store the code in a file ending with .bat and right click -> run as admin. Done

You don't need a script as long as you've installed the latest version of Sunshine.

And you need to launch the Desktop app in Moonlight, to sign back in, otherwise it will fail until you sign back in

I am using the latest version I downloaded 3 days ago and I HAVE to use the script, or else I can't even launch the Desktop app in Moonlight (from Mac).

@ReenigneArcher
Copy link
Member Author

I am using the latest version I downloaded 3 days ago and I HAVE to use the script, or else I can't even launch the Desktop app in Moonlight (from Mac).

You should just be able to disconnect from your RDP session, and then connect using Moonlight. I don't believe you need the bat script I posted anymore, as long as you disconnect yourself. You can disconnect via "start/power/disconnect".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed This issue has been fixed and will be available in the next release. os:Windows OS is Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.