Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is most likely no translated for the post!





Waking up a Mac wit...
 
Share:
Notifications
Clear all

Waking up a Mac with Wake On LAN

Page 1 / 2

 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

So this topic is a continued conversation on how to use miniWOL to wake up a Mac from sleep started by Ryan.
Since the infor is getting a little out of hand, I (Hans) have started this forum topic.


 

So some observations I did while testing and searching for an answer;

1) Port numbers ... 

I didn't get any smarter here, except that (see end of this post) that Port 4343 seems to do something.

I've tested the default port (9), which didn't work, and the common alternative port (7), which didn't work either (same as on your setup).

In an old post I did read someone using port 4343 for WOL which did trigger did show up in the power management log:

pmset -g everything | grep Magic

You can see that the WOL packets (over port 4343) indeed arrive at the Mac.

2020-12-03 22:19:25 +0100 WakeDetails         	DriverReason:Enet.MagicPacket - DriverDetails:Magic packet received

(even though nothing happened - my Mac remained dark)

Note: port 9 WOL also do appear in the power management log.

 

2) I wonder when a Mac really goes to sleep.

When looking at the power management event with the code below, you'll see a lot of "sleep preventers".

pmset -g log | grep sleep | tail -n 10

Since I'm not very knowledgeable on the "pmset" details, there could be conflicts with different kind of sleep modes the Mac may be using.
I did disable Power Nap on my Mac for that reason, but in the end it didn't make much of a difference.
Maybe we have to wait longer.

All-in-all I wouldn't expect this to matter. At least I'd assume that a WOL magic packet should tell the Mac to "wake up", even if it's not entirely asleep.

Another thing that makes me wonder about WOL on a Mac, is the explanation of "Wake for network access":

    "Even in sleep mode, wakes to provide access to shared resources, such as shared printers or Music playlists."

Granted this is a help page, and when have those ever been helpful, but it doesn't mention WOL, which you'd assume would be needed for this to work.

On the other hand the man page of "pmset" states:

    "womp - wake on ethernet magic packet (value = 0/1). Same as "Wake for network access" in the Energy Saver preferences."

Confusing to say the least 😉 

 

3) How I'm testing

So to get an idea what may be the issue, which I still haven't found, I use this Terminal statement:

date; pmset sleepnow; date; pmset -g everything | grep Magic

Which prints the date and time, puts the Mac to sleep.
Once the Mac wakes up again, it continues by printing the date and time again (soI can find those in the log) and show the "Magic packets" from the power management log. 

This is what happens on my Mac Pro:

At sleep (0 seconds), the screen goes OFF, and the cooling fan keeps spinning for a few more seconds.
Sleeping for 10 seconds - Cooling fans stop.
Sleeping for 17 seconds - USB devices are turned OFF (LEDs on my keyboard go OFF).
Sleeping for 45 seconds - USB devices are powered ON again and my external disk starts spinning (I assume some Time Machine activity).
Sleeping for 97 seconds - All OFF -- USB devices go OFF again, external disk spins down, LEDs on keyboard OFF, fans OFF.

After that, when I send the WOL magic packet (port 9 and port 4343 have the same effect, so I'd stick with port 9):
USB devices are powered ON again (LEDs on keyboard ON), but the monitor remains black.
Moving the mouse doesn't do anything - screen remains black until I touch a key on the keyboard or a mouse button.

So, maybe this gets us further. Maybe you can test this on your Mac.
Once your Mac went through all these steps, and the USB devices are finally on again, maybe moving the mouse to the other screen (even though you can't see it) may turn the monitor ON again?

Still not the solution we're looking for of course, but it may get us close.


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

Almost forgot:

I don't think Apple is preventing WOL from non-Apple devices. The package is received (Wireshark and the Power Management log confirm this), and devices are powered again (my USB devices). Just the screen is not turned ON.

Then again, when I do touch a key on the keyboard, the Mac makes its usual mechanical sound when it starts up (I suspect the fans).
So we're not quite there yet 😞 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

I did see something interesting, but it would be kind-a sad if we would have to go that route;

There is a statement to mimic "user" movement (mouse/keyboard) to prevent a machine from going to sleep (or maybe even wakeup the screen?)

caffeinate -u -t 1

So I got this to work, but it feels like toooo much, but it works:

  1. In System Preferences -> Sharing -> enabled "Remote Login" (this is wat is called SSH).
  2. Put your Mac to sleep and wait for the USB devices to power down.
  3. Use miniWOL to send the magic packet (port 9) -- you'll see the USB devices being powered again.
  4. On your Windows PC, open a Command Prompt and type (replace username and ip_address_mac):
    ssh username@ip_address_mac
  5. If this is the first time you do this, it will ask if you want to store the key fingerprint - enter "yes". A next time it will not ask this again.
  6. Next you will have to enter your password (the username and password are the ones you use to login to your Mac the usual way)
  7. You're now in a "remote" Terminal on your sleeping Mac.
    Type:
    caffeinate -u -t 1

    and press ENTER. Your Mac will now wake up ...

 

Granted, NOT the most convenient way to do this, but it does tell me the Mac is awake after a WOL, however the "user interface" isn't active yet.

In the meanwhile I have installed ShareMouse on a Windows machine and a Mac.
the suggested test I mentioned in a previous comment unfortunately did not work. 😞 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

p.s. I just released a new miniWOL version for Windows, since I found a tiny bug (MAC address detection) while testing 😊 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

Ryan's post;

Sorry for the delay – I am waiting for my forum registration email to go through and then will post in the proper forum.

As a quick note, I was able to replicate your command prompt of caffeinate and achieve the same results…it will now wake my Mac remotely from my PC. So on one hand you have solved my problem, but on the other I agree it would be much much cleaner if I could just right click on the MiniWOL icon on my PC and have this behavior mimicked when I select my Mac under network devices to wake up.

I tried creating a Macro on my keyboard to just run that command, but it’s getting hung up on inputting the password once cmd is open. Regarding the ShareMouse test…agree this doesn’t work as ShareMouse drops the connection between the two machine when one goes to sleep (you can see the ShareMouse icon change as it happens). 


ReplyQuote



 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

I wrote a little application to see if I can have caffeinate run as soon as the Mac wakes up.
Funny observation: my little program gets a notification with the wake-up message, at the correct time stamp.
But it will not execute anything until the Mac screen is awake. This is very unfortunate, because this would be an easy fix that others could run on their Mac as well. 😫 

 

Another trick you can explore is SSH access without a password, which involves using a key - still not a great solution in my opinion, but at least it will overcome the password hurdle.

The steps are explained in the article, but the short version is this (execute on your Windows machine):

Note: I assume MYUSERNAME is your windows username, MACUSERNAME your MacOS username, and 192.168.1.100 to be the IP address of your Mac!

Make a directory for your SSH key:

mkdir C:\Users\MYUSERNAME\.ssh

Generate a key:

ssh-keygen -f C:\Users\MYUSERNAME\.ssh\id_rsa -t rsa -P ""

Send the key to your Mac (this is one single line - just in case your browser wraps the line):

type C:\Users\MYUSERNAME\.ssh\id_rsa.pub | ssh MACUSERNAME@192.168.1.100 -o StrictHostKeyChecking=No "umask 077; test -d .ssh || mkdir .ssh ; cat >> .ssh/authorized_keys || exit 1;"

After having done this, I do recommended reading the article to see what the expected outputs should be, you can send the caffeinate command through SSH (from your Windows computer) like so:

ssh MACUSERNAME@192.168.1.100 "caffeinate -u -t 1"

So if that would be the approach, which I'm still not fond off, then I could consider adding a script option (with a delay timer, or a PING test) to miniWOL.
I'd actually rather not, since the goal of miniWOL is to be simple to use and understand.

So I will try to see what else I can find to wake up the screen.


ReplyQuote
(@gwinnr)
New Member
Joined: 3 months ago
Posts: 2
 

So given that I am a complete novice (though as you may have seen can follow instructions), I will say that I have been able to easily replicate all the behavior you have observed with these intermediate tests/solutions. I would agree that it would still be much better to have the functionality built directly into MiniWOL, though as a user I would say if one or two additional one-time configuration steps were necessary to get this to work well with Mac then its still a big win. For example, if you needed to direct Mac users to enable the remote login in System Preferences and provide a one time password that doesn't seem like too much to ask even a basic user (people that can't handle that probably won't even know how to search for this type of application). 

Something interesting happened this morning, but unfortunately I have no idea how to check it. I used my connected peripherals to wake up my PC and then about one minute into my normal routine of checking email etc. my Mac woke up and opened the login screen on my top monitor. The Mac was asleep and in clamshell/closed mode behind the desk and had been in that state since last night. There are no peripherals plugged into it. ShareMouse and MiniWOL were enabled on both machines and are configured for startup. Something woke the Mac up... 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

Glad you made your way into the forum 😁 

 

Don't worry about being a novice - the idea for miniWOL is that everybody should be able to use it, and also keep in mind that we all have been a novice, and I most certainly do not know everything either 😁 

 

Interesting that you Mac randomly woke up. You could try and see if this will reveal anything useful (to be used after that happened):

pmset -g everything | grep Wake | tail -n 20

If it has been a while that this happened then you could try looking by timestamp - which will probably be a challenge to even guess what time that happened.

pmset -g everything | grep 12:1 | tail -n 20

This greps all lines that have "12:1" in it, so 12:10 .. 12:19 would be listed, and limites the list to the last 20 lines (tail -n 20).

 

As far as I can see:
WOL does indeed wake up the Mac, but only in a, what may be called, "dark wake" state.
In this dark wake state the monitor remains off and applications actually do not "run".
Interestingly certain network services (like file sharing and SSH) do seem to be running in the background (if enabled).

I tried doing a ping when my Mac is in this dark wake state, and a ping does work - it will however not wake up the Mac display.


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

Note:

As far as enabling Remote Access goes; I'm not a fan of enabling this for this purpose. After all, you'd open up a door that others could try to abuse.
I'm personally not worried in my network, but ya never know 😉 


ReplyQuote
(@gwinnr)
New Member
Joined: 3 months ago
Posts: 2
 

@hans

Last login: Thu Dec  3 21:03:01 from [[Ryan PC]]

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.

For more details, please visit https://support.apple.com/kb/HT208050.

Ryans-MBP:~ ryansmacbookpro$ pmset -g everything |  grep Wake | tail -n 20

2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleDisplaySleep "com.apple.audio.context799.preventuseridledisplaysleep" 12:20:06  id:0x0x5000095b0 [System: DispWake IntPrevDisp kDisp]        
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleSystemSleep "com.apple.audio.context799.preventuseridlesleep" 12:20:06  id:0x0x1000095ab [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleDisplaySleep "com.apple.audio.context798.preventuseridledisplaysleep" 12:20:06  id:0x0x5000095bc [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleSystemSleep "com.apple.audio.context798.preventuseridlesleep" 12:20:06  id:0x0x1000095b5 [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleDisplaySleep "com.apple.audio.context806.preventuseridledisplaysleep" 12:20:06  id:0x0x5000095bf [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleSystemSleep "com.apple.audio.context806.preventuseridlesleep" 12:20:06  id:0x0x1000095b7 [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleDisplaySleep "com.apple.audio.context808.preventuseridledisplaysleep" 12:20:06  id:0x0x5000095cb [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleSystemSleep "com.apple.audio.context808.preventuseridlesleep" 12:20:06  id:0x0x1000095c9 [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleDisplaySleep "com.apple.audio.context805.preventuseridledisplaysleep" 12:20:06  id:0x0x5000095bd [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleSystemSleep "com.apple.audio.context805.preventuseridlesleep" 12:20:06  id:0x0x1000095b4 [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleDisplaySleep "com.apple.audio.context810.preventuseridledisplaysleep" 12:20:06  id:0x0x5000095cf [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleSystemSleep "com.apple.audio.context810.preventuseridlesleep" 12:20:06  id:0x0x1000095ce [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleDisplaySleep "com.apple.audio.context807.preventuseridledisplaysleep" 12:20:06  id:0x0x5000095cd [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleSystemSleep "com.apple.audio.context807.preventuseridlesleep" 12:20:06  id:0x0x1000095cc [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleDisplaySleep "com.apple.audio.context809.preventuseridledisplaysleep" 12:20:06  id:0x0x5000095ca [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:01 -0500 Assertions          PID 202(coreaudiod) Released PreventUserIdleSystemSleep "com.apple.audio.context809.preventuseridlesleep" 12:20:06  id:0x0x1000095c8 [System: DispWake IntPrevDisp kDisp]          
2020-12-04 09:00:30 -0500 Assertions          PID 355(NotificationCenter) TimedOut DisplayWake "com.apple.notificationcenter.sleeping-note" 00:00:29  id:0x0xe0000a172 [System: PrevIdle DispWake IntPrevDisp kDisp]          

Total Sleep/Wakes since boot at 2020-12-02 09:08:56 -0500 :6

Dark Wake Count:3

User Wake Count:5

Ryans-MBP:~ ryansmacbookpro$ 

 


ReplyQuote



 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

Hi Ryan,

The log is not showing in why your Mac woke up unfortunately.

I did some searching on running an application on your Mac, which would wake up your display when there is a "dark wake", only to realize that this may come with the undesired side effect that your Mac will wake up at times where we'd really not want to see the display turn on. For example when your Mac is running a task in the background (eg. Power Nap and similar things).

As for adding a command line option: the tricky part would be to know when the Mac is awake enough to execute something like an SSH session. A simple PING will not be reliable as the machine may already respond to pings, but it may still take several seconds before SSH would work.

I haven't given up yet 😋 

 


 

Tip : I see you haven't switched from the old Bash to ZSH (z Shell) yet, which has become the default since Catalina (I think).
In no way critical and not a big deal, but if you want to get rid of that message just execute:

chsh -s /bin/zsh

I was a little nervous about switching at the time, since I was afraid it could break some of my scripts.
After running zsh for a while now, I can say that I have not ran into any script issues. There are differences though, some more info can be found in this article.


ReplyQuote
(@meestor_x)
New Member
Joined: 3 weeks ago
Posts: 4
 

Hello;

Just found this thread, and hoping that maybe there's a solution to me not being able to wake my MBP 16".

pmset -g everything | grep Magic

Shows nothing in my case. miniWOL (and other programs I've used) wake my Windows PCs without issue, just can't get my MBP to wake up. Gone through the Energy settings, pmset settings, tried many different Ethernet dongles, no joy at all.


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

Hi Meestor_x!

First thing I'd like to say is that I have been testing this all morning with my MacBook Pro, and haven't found a solution yet ...
(note: all this works just fine on my Mac Pro, just not on my 2016 MacBook Pro)

- China USB-c Ethernet dongle: whatever I tried, my MBP did not wake up.
- Build in WiFi: my MacBook Pro refuses to wake up as well.
- I've tested several different WOL utilities, but no dice. 
- Tested with WireShark if the packets arrived: yes they did.
- Tested with PING before and after sending WOL: no dice.
- Verified "womp" in Terminal: it is set.

I'll do some more testing, just figured I'd post these initial findings first.

 

Note: some suggestions I've added for others that may read this in the future.

  • Initially I was wondering if you'd be trying to do WOL over WiFi, but you're not (using Ethernet dongles) - did you try to do a WOL over WiFi?
  • When you MBP goes to sleep, can you see if the Ethernet dongle remains powered?
    I read that most USB dongles are problematic, because they either turn off (no power) or always remain on (therefor not doing anything with a wake-up call).
    From what I've read so far, this appears not an uncommon under Windows either (YMMV).
  • Sometimes a SMC reset helps (Apple Support).
  • Do you see "Wake for network access" (dongle seems to support WOL) or "Wake for WiFi network access" (dongle does not seem to support WOL)?
    (note: I'm not sure if this is a fact or not)
  • Could it be that the Mac is awake but the screen remains off? 
    (see this caffeinate post - enable remote login, put Mac to sleep, 2 minutes later send WOL, try SSH'ing into the Mac)
  • Is your MacBook Pro receiving WOL packets? (explanation how to do this)
  • Terminal: check and/or set WOL (you already did this):

Type:

pmset -g live | grep womp

 

This should show either "womp     0" (=WOL OFF) or "womp     1" (=WOL ON).
You can enable WOL with:

sudo pmset -a womp 1

After that, try "pmset -g live | grep womp" again to see if it stored the change.

 


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

Right after posting that I had some strange success ... well, half way anyway.

I've connected my MBP to ethernet with the China USB-c Ethernet dongle AND WiFi.
I'm sending a WOL to the WiFi connection, but my MacBook Pro remains dark.
However ... the Ethernet dongle can now be pinged and I have SSH access.

Sending this in SSH turns on the display:

caffeinate -u -t 1

 

Obviously, NOT a convenient way to do this.

 

Another thing I found was that Apple products may rely on a Bonjour Sleep Proxy.
I'll investigate that one and see what entails and can do for us.


ReplyQuote
 Hans
(@hans)
Noble Member Admin
Joined: 8 years ago
Posts: 1775
Topic starter  

I should elaborate a little more about my last finding;

I have my MBP connected through WiFi and the Ethernet dongle.
When I put the Mac to sleep, after roughly 2 minutes it actually seems to go to sleep.
At that point, I can still ping the WiFi IP address (which doesn't wake up the MBP).
However, I cannot ping the Ethernet IP address.
Sending a WOL to the WiFi IP address (MAC address), wakes up the Ethernet connecting and I can ping it. The screen remains dark though.
When "Remote Login" is enabled (under System Preferences -> Sharing), I can SSH into the MBP and send the caffeinate command and the screen wakes up as well.

Notes:

- I had the Mac wake up (screen still dark) with ports 7, 9, 4343 and 50000 (seems to be an ancient port used by old Macs).
- I read in the Apple documentation that the laptop lid needs to remain open for WOL to even work?

 

I did also read up on the Bonjour Sleep Proxy.
I did find a good explanation though, on how this works and can be tested, but I do not have an Apple device that can function as one (AppleTV or AirPort).
To be honest, I'm a little weary of tinkering with "/System/Library/LaunchDaemons/com.apple.mDNSResponder.plist".


ReplyQuote



Page 1 / 2

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: