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

Connection errors when using msrdcex prevent new connections. #132

Open
rn-jernst opened this issue Dec 13, 2024 · 5 comments
Open

Connection errors when using msrdcex prevent new connections. #132

rn-jernst opened this issue Dec 13, 2024 · 5 comments

Comments

@rn-jernst
Copy link

Currently an error connecting to a session prevents additional connections.

Steps to reproduce.

  1. Create an AVD application/desktop with a target executable or host that does not exist.
  2. Use msrdcex to connect to that resource.
  3. Leave the error window open.
  4. Launch msrdcex again with a known working application.

Current behavior:

The second launch of msrdcex does not attempt to connect until the error box is closed on the first msrdcex instance.

Expected behavior

The second instance of msrdcex should launch instantly.

@awakecoding
Copy link
Collaborator

MSRDC does seem to be misbehaving when it has multiple processes like this, do you know if this is specific to MsRdpEx, or if it happens with "vanilla" MSRDC as well? If it's not MsRdpEx-specific, then it would mean the problem is in MSRDC, and we'd have to figure out a way to change the behavior with the API hooking

@rn-jernst
Copy link
Author

I was able to reproduce this with the vanilla MSRDC.

@awakecoding
Copy link
Collaborator

From PowerShell, you can use "Get-Process msrdc | Stop-Process" to get things back on track. I have often seen zombie msrdc.exe processes throughout a day of launching it several times for development. I don't know if there's really a way I can force it not to call into the existing msrdc process, and it doesn't seem to always do it, only at specific times like the case you've found.

@rn-jernst
Copy link
Author

rn-jernst commented Dec 13, 2024

The only problem with Get-Process msrdc | Stop-Process is that any currently open desktops or remoteapps to AVD are killed as well. It seems the error process is spawned as an additional sibling to the currently open sessions, and it then prevents more siblings from spawning.

@rn-jernst
Copy link
Author

I created a work around using FindWindow and sending WM_CLOSE to the Handel with the class TSC_CONNECTING_DIALOG_PARENT_WNDCLASS It's not ideal but it works.

The method below could be called with a flag on MSRDCX, but that feels a little hacky because the issue is with a process outside the scope of this project.

    public static void CloseRdcErrorWindows()
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
        const UInt32 WM_CLOSE = 0x0010;
        void CloseWindow(IntPtr hwnd)
        {
            SendMessage(hwnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
        }

        List<IntPtr> Windows = FindWindow.GetWindowHandles("msrdc", "TSC_CONNECTING_DIALOG_PARENT_WNDCLASS");
        foreach (IntPtr Window in Windows)
        {
            try
            {
                CloseWindow(Window);
            }
            catch
            {

            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants