Screen sharing fails to connect
I have chronic problems connecting to my headless Mac Mini using Mac OS X's builtin screen sharing. Usually it works fine, but sometimes it will not connect.
It goes like this:
I initiate a connection (either by clicking the Mac Mini in the sidebar in a Finder window and choosing the "Share Screen..." button, or else by launching /System/Library/CoreServices/Screen Sharing.app
and enter the Bonjour name "macmini.local
"), the throbber appears with the word "connecting", then the throbber disappears. If it's going to connect successfully, it does so at this point. Often, however the throbber disappears and nothing replaces it. The Screen Sharing app remains active, no message appears, and nothing happens, no matter how long I leave it. No connection seems to occur.
I cannot cause the issue to occur reliably, but once it does occur, it can be observed from several different mac clients. If I reboot the remote machine (via shutdown over ssh), it goes away and I connect without problem, but I'm seeking a better solution.
Checking the processes running on the remote Mac Mini via ssh, I see two processes, /System/Library/CoreServices/RemoteManagement/screensharingd.bundle/Contents/MacOS/screensharingd
owned by root, and a child process /System/Library/CoreServices/RemoteManagement/ScreensharingAgent.bundle/Contents/MacOS/ScreensharingAgent
. If I try to kill either of these processes, they change their PID but remain running, and it does not allow me to connect.
From this thread Restart Screen Sharing Service on Mac mini Server I learned how to properly restart the screen sharing daemon. Or actually two methods. Not sure which one is proper, so I do them both. Does not help, still cannot connect.
From this thread Why is Mac-to-Mac screen sharing just hanging? I learned the suggestion to connect by IP address instead of bonjour name. Upon trying this, I get the login window, instead of the "connecting" throbber. Still no connection, though. And quitting Screen Sharing on the local machine doesn't get rid of the stuck login window. The only way to rid yourself of it is to kill NetAuthAgent, as I learned in this thread: How to kill stuck Screen sharing authentication dialogue?
Both machines run Lion (10.7.4), though I've been observing this behavior since 10.6, perhaps 10.5 I can't remember. Remote machine is a 2009 Mac Mini, and the local machine is a MacBook Pro (this behavior has been duplicated on many different client machines though).
Surely there must be some process, server, daemon on the remote machine that I can bounce? Something short of rebooting?
Solution 1:
ssh into the remote Mac and kill the screensharingd
daemon.
$ ps ax | grep screen
1234 ?? Ss 0:00.02 /System/Library/CoreServices/RemoteManagement/screensharingd.bundle/Contents/MacOS/screensharingd
$ sudo kill 1234
It works for me. I have Mac OS X Lion on both local and remote computers.
Solution 2:
Screen sharing by itself worked perfectly well when enabled in my Mac Mini sharing preferences. However, as soon as I enabled Remote management, it removed Screen sharing and stopped working claiming that Screen sharing is handled by Remote management … what ever that is. I just disabled Remote management and used Screen sharing to get around the problem.
Solution 3:
Logging out of MobileMe on the client machine solved this problem for me.