Windows Remote Desktop Client fails to connect with error code 0x4

When I connect to my Windows 10 machine from my Mac via Microsoft Remote Desktop client v10 or from Windows I’m getting an error: Your session ended because of an error. If this keeps happening, contact your network administrator for assistance. Error code: 0x4

I reported this issue to MS via their Report Issue form on Mac Remote Desktop client and got the following response:

Set this key to a high value, like 10,000 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server



Once I followed these recommendations the problem stopped.

Mac Won’t Sleep

On the rare occasion that you go to put a Mac to sleep and, well, it won’t sleep, there’s an easy to way to find out what the holdup is. Though this is a somewhat technical approach, it should give a good starting point to anyone who’s confused as to why something like automatic sleep isn’t taking effect, and hopefully provide a quick resolution to the problem.

pmset -g

$ pmset -g

System-wide power settings:
Currently in use:
 lidwake              1
 autopoweroff         1
 standbydelayhigh     86400
 autopoweroffdelay    28800
 proximitywake        0
 standby              1
 standbydelaylow      10800
 ttyskeepawake        1
 hibernatemode        3
 powernap             0
 gpuswitch            2
 hibernatefile        /var/vm/sleepimage
 highstandbythreshold 50
 displaysleep         2
 sleep                1 (sleep prevented by coreaudiod)
 acwake               0
 halfdim              1
 tcpkeepalive         1
 disksleep            10

You can see

 sleep                1 (sleep prevented by coreaudiod)

sleep is blocked by coreaudiod.

then pmset -g assertions

$ pmset -g assertions

019-03-25 17:23:40 +0800 
Assertion status system-wide:
   BackgroundTask                 0
   ApplePushServiceTask           0
   UserIsActive                   1
   PreventUserIdleDisplaySleep    0
   PreventSystemSleep             0
   ExternalMedia                  0
   PreventUserIdleSystemSleep     1
   NetworkClientActive            0
Listed by owning process:
   pid 174(coreaudiod): [0x0002b01700018c7a] 00:36:20 PreventUserIdleSystemSleep named: “,0,1,1:0.context.preventuseridlesleep” 
Created for PID: 9697. 
   pid 119(hidd): [0x0002b7e100099838] 00:00:00 UserIsActive named: “” 
Timeout will fire in 120 secs Action=TimeoutActionRelease
No kernel assertions.
Idle sleep preventers: IODisplayWrangler

Now We Know how to cancel the PID . The problem solves