Preventing server sleep during streaming?

Is there a setting somewhere to tell the Plex server to send a “do not sleep” message to the Energy Saver process on the Mac? My Mac server is set to sleep on idle, but it’s sleeping during streaming to a client. Not fun when you’re in the middle of watching something and it disconnects.

Thanks in advance.

Unless this documentation is outdated, this is what Plex server should probably be doing to prevent sleep while streaming.

https://developer.apple.com/library/content/qa/qa1340/_index.html

"Applications have a chance to prevent sleep by calling IOCancelPowerChange”

Can one of the devs check for this and then file a bug with Apple if it’s not working?

This apple support page may assist. Some earlier model Macs have this issue, I have a more recent model now and have no issues running High Sierra. Then again others have had issues with remote access but that’s another story.

If this does not help you can try the following suggestions.

Reset the SMC of your Mac – Apple Support (AU).

This isn’t a problem with the Mac — it’s a problem with Plex server. Other services keep the Mac awake while they are active. I’m not setting the server to “never sleep” — this is 2017. That’s the point of the “Wake for network access” setting in your screenshot.

Well to answer you I’m using the public release not the “pass” release and have no issue. So if you feel so strongly it’s not a Apple issue roll back. You will need to change your PMS settings to “Public” and manually install the public release. When it’s fixed you can update again. As for 2017 that finished a fortnight ago and I do not understand your reference to the issue in that vain.

If you would like to elaborate on error messages or behavior during your issue it may relate to other known problems. What happens with your stated disconnect. It is strange no one else has chimed in with similar issues in the discussion.

https://plex.tv/downloads

Thanks. I’ll give that a try. And yep, 2017 is over. Time flies!

So I used the pmset terminal command to check, and Plex is registering as “ PreventUserIdleSystemSleep” while streaming. I’ll do some more digging.

pid 1407(Plex Media Server): 00:00:08 PreventUserIdleSystemSleep named: “PreventUserIdleDisplaySleep”

http://hints.macworld.com/article.php?story=20120701234338952

This maybe the problem. recently i was having issues during streaming and put it down to other processes. Removed Spotlight indexing from PLEX storage drives and stopped Automatic backup with time machine.

So I did some more digging, and I found that streaming from iTunes to an Apple TV or another iTunes client sets “NetworkClientActive” mode on the server and the Mac does not go to sleep during the stream. Plex streaming uses “PreventUserIdleSystemSleep”. iTunes keeps the Mac awake during stream, Plex server does not. Mounting a file server from the same mac also uses “NetworkClientActive” and also keeps the mac from sleeping.

It could be a bug with macOS 10.13.2 and PreventUserIdleSystemSleep. We’ll see what 10.13.3 does (should be out soon) and I will follow up again.

I’m surprised no other Mac users have reported this. I guess most people aren’t using a mac as a server, or are keeping their server from sleeping, or it has something to do with using older mac hardware as the server.

Oh look…

So it’s not just me. These users gave up and rolled their own solution through a background script. I’m still having the same issue under 10.13.2. The issue is definitely related to “Wake On Lan” — the Mac wakes up when a Plex client makes a request, then the server starts to stream, the server makes the PreventUserIdleSystemSleep assertion, then the Mac still goes to sleep when it hits the sleep on idle timer (in spite of the assertion and the open network connection).

Might be worth switching Plex to the “NetworkClientActive” assertion since this is what iTunes uses during streaming.

1 Like

Also possibly related:

https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventuseridlesystemsleep

"This assertion does not put the system into Dark Wake.”

So it sounds to me that would mean it wakes, but this assertion won’t keep it awake. Which would mean the Plex server is using the wrong call here. It should likely use “NetworkClientActive” like iTunes, SMB, and other network-based services or “PreventSystemSleep”” while streaming. It should of course release the assertion when clients are no longer streaming. This would allow the server to go back to sleep on idle, and in turn the server can be re-awakened by a streaming client through Bonjour sleep proxy and Wake On Lan.

https://developer.apple.com/documentation/iokit/kiopmassertiontypepreventsystemsleep?language=objc

“When asserted and set to level kIOPMAssertionLevelOn, the system will prefer to enter the Dark Wake state, or remain in Dark Wake if already there, rather than go to sleep.”

I have the same problem on my Mac mini running high Sierra acting as the plex server where it won’t stay awake when streaming.

hi, any news regarding this problem? it affects my mac mini as well… PMS version 1.14.1.5488

This is happening to me as well - I can’t figure out how to make it stop!

I’m pretty sure my MacBook Pro was able to wake up to stream media to my phone. However, it quit after I hooked up a docking station and monitor to it. No idea why that would break that feature, but I just don’t have the gumption to figure out the problem-not really a computer person. Power settings are set to “Wake for network access” FWIW.

I am also having this same issue with PMS ver 1.15.4.993 running on a mac mini. Any update?

Ive been running Plex on my 2012 Mac mini 2.5 Ghz i5 since 2014 and I keep it on never sleep because anything else will cause issues with streaming Plex. I help my mini out by keeping the pass word log in off, auto log in Plex and my Nas hdds when powered on and let it shut down and wake for a few hours in the middle of the night while im sleep. I was looking at this forum to see if anyone finally came out with a solution but i guess they havent. =\

I have had this same problem for many years. Running an ancient 2009 Mac mini as a Plex server; replaced the drive a few times and upgraded ram but never could figure out why the “Wake for network access” feature never works with Plex and/or why the Mac mini does not stay awake while streaming with Plex. I stopped looking for a solution years ago as it seemed (for years) no one else was complaining about it but now there is this wonderful thread. My temporary solution has been to just keep the Mac mini awake and put it on a daily schedule to go to sleep and then wake up in the middle of the night while I was sleeping. Would love to finally get a solution to put this issue in its entirety to rest. I am not a super savvy computer person, got no idea how to do terminal commands or write code/scripts.

Been noticing my laptop display staying awake sometimes lately, and using pmset tracked it down to being due to Plex, even though I’m not streaming anything at the time… rather annoying.

@Austinite007 I agree it’s a bit frustrating that the Plex team seem unaware / unable / unwilling to fix the issue. But I can recommend using my script as a workaround in the meantime - I’ve had it installed on my 2010 Mac Mini for the past couple of years, and it’s been working just fine. See instructions here: PLEX server should keep Mac awake after wake-on-lan