INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Force restart on resume from standby  (Read 2994 times)

stricko

  • Galactic Citizen
  • ****
  • Posts: 423
Force restart on resume from standby
« on: March 21, 2020, 01:22:17 am »

Hi there, I have a pretty standard server / multiple client MC26 setup, with the clients running almost exclusively in Theatre View. One issue I've never been able to resolve satisfactorily is waking the clients from standby. When I boot a client, MC26 wakes the server if it needs to, and happily reconnects to the server library. But if I put a client into sleep mode with MC running and then wake it, MC on the client just seems to hang, or goes into what I call zombie mode. It will allow navigation of the Theatre View menus, but when I ask it to play anything, it hangs and then MC crashes.

I raised this a long while back, and I think I was told that it should work, but I've never seen it happen. I just force the client PC to shut down on standby and have accepted that I have to manually power the client up to force a clean boot which then works fine. But I'm now playing with a Harmony hub and Amazon Echo, and the one clunky bit is having to manually switch on the client PCs (they are hidden in cabinets).

As a work around, I'm looking at triggering a command or script when the PC resumes. The brute force option would be to force the PC to restart, which would be OK as it is booting from SSD, and basically just fires up MC, so is pretty quick. A more elegant option would be just to restart MC, which I assume would then cleanly reconnect to the MC server.

Is it possible to run a MC command which will make a ruuning instance of MC restart?
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Force restart on resume from standby
« Reply #1 on: March 21, 2020, 01:49:05 am »

You can issue the two following commands:
mc26 /mcc 20007
mc26

That will cause MC to exit and restart.

If you also want it to go to theater view, additionally issue:
mc26 /mcc 22001,1
Logged

stricko

  • Galactic Citizen
  • ****
  • Posts: 423
Re: Force restart on resume from standby
« Reply #2 on: March 21, 2020, 01:59:50 am »

Thanks. I'd just tried it with a simple MC26 /restart but it restarted in zombie mode. Once MC26 crashed, the restart fired in. I'll try your approach.
Logged

wer

  • Citizen of the Universe
  • *****
  • Posts: 2640
Re: Force restart on resume from standby
« Reply #3 on: March 21, 2020, 03:25:52 am »

Right, what I gave you was a full shutdown and restart.  It should fix anything that can be fixed by merely stopping and restarting the application.  The developers would have to comment if the /restart option does something less.  If something is confused on the server side by the client going to sleep, these methods might not suffice.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Force restart on resume from standby
« Reply #4 on: March 21, 2020, 07:00:45 pm »

You can also just set up a command to load the server Library, which will properly activate the Client, and wake the MC Server if required. The command would be:

mc26.exe /Library <library name>

Naturally you will need to quote the Library name if it is more than one word. i.e.

mc26.exe /Library "My HTPC Server"

As the MC installation puts a copy of mc26.exe in C:\Windows\SysWOW64 and C:\Windows\System32, the executable will be found and executed with parameters. The MC Restart command should have worked as well, although it is a bit more brute force. It will restart MC with the default Library and other parameters as per the "Options > Startup" settings.

mc26.exe /Restart

If the MC Client is set to connect to the MC Library Server, then a restart of the Client will also send WOL commands to the MC Server.

Reference: https://wiki.jriver.com/index.php/The_Command_Line

=========================================================================================
To automate the above process, use Task Scheduler and set up a task to run whenever the Client PC wakes from sleep. The Task trigger would be:

Log:         System
Source:    Power-Troubleshooter
Event ID: 1

Well, you should be able to use the Task Scheduler to do this. It has given me trouble in the past, and I just tried again with no success so far. I'm going to play with it some more later and will let you know if I get it working.
=========================================================================================

BTW, the Zombie should only happen if the MC Server has gone to sleep "underneath" the Client. When that happens, and the Client is woken, the MC Client will use the local copy of the Server Library for navigation around menus, and some very basic tasks, but it won't wake up the server. In the Zombie state running a command as above should wake the MC Server and all should work again.

If the MC Server hasn't gone to sleep, but the MC Client has and is woken, you shouldn't see Zombie mode.

This has been discussed before, lots of times. I still don't quite understand why JRiver don't just issue WOL commands to the Server when a Client wakes up, by default. WOL commands are non-destructive, so if the Server is already awake they will do nothing, and the Client will work as expected. So far that functionality hasn't been added.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Force restart on resume from standby
« Reply #5 on: March 21, 2020, 11:56:35 pm »

Okay, I played around with using a Task in Windows 10 Task Scheduler. It seems that Task Scheduler works a bit better than it used to, and I was just compensating for issues that are no longer present... mostly. It still gives you strange results under some circumstances however.

To set up a Reload of MC Server Library, follow the outline and Images below.

Create a Task in Task Scheduler. I created a folder (RoderickGI) for my specific Tasks, and created the Task in there. But you can put it anywhere. Give the Task a meaningful name, and a description if you want to.

Creation image.


The important information on the General tab is that the User must be logged in to run this Task. MC only runs with a User logged in, so this is mandatory. The Task will fail without it, in strange ways.

General image.


Set up the Trigger for this Task as per the image. Make sure the Task in enabled.

Triggers image.


Set up the Actions as per the image. If your MC Server name includes more than one word, make sure you put quotes around the name. In my case, my MC Server Library is called "WILMA Server Library". Note also that I tested this using MC25 on my Workstation. You will need to change the executable called to mc26.exe. The program arguments must be in the arguments box, and there is no need to put anything in the "Start in" box. Note: On my Workstation I am logged in as an Administrator. If you are logged in as a normal User these settings should be the same, but the Task may require a "Start in" value. If so, just set it to the MC AppData Temp directory. i.e. "C:\Users\[UserID]\AppData\Roaming\J River\Media Center 26\Temp".

Actions image.


Set up the Conditions as per the image. As you will be connecting to the MC Server, you will need a network connection for it to have any chance of being successful.

Conditions image.


Set up the Settings as per the image. Note that you only need the "Allow task to be run on demand" setting for testing the Task. You can then right-click the Task in Task Scheduler and select "Run", or select it and click the "run" link on the right, to run it and confirm that it works. I tend to leave that setting turned on anyway. Note that if Window 10 thinks the Task worked correctly there will be six lines in History from "Created Task Process" to "Task completed", and the Return Code for the "Action completed" line will be 0 (zero). You should still check that MC actually started if it wasn't running, and loaded the MC Server Library correctly. I loaded a local Library and then ran the Task to check it worked properly, as it is easy to tell when the Library changes, by just reading the Display area at the top of Standard View.

Settings & History image.


If MC wasn't running and you have it set to start in Theatre View, MC will start, load the Server Library, and display Theatre View.
If MC was running and the PC has just been woken, MC will load the Server Library and display whatever view (Standard or Theatre) it was on before.

QED
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

stricko

  • Galactic Citizen
  • ****
  • Posts: 423
Re: Force restart on resume from standby
« Reply #6 on: March 28, 2020, 07:27:23 am »

Thanks for all this stuff. I've been playing around, but the the results are inconsistent. I've got one machine behaving reasonably well but the other is proving more troublesome. May be due to messing around with power states in the past, so I'm going to do a clean rebuild to see if thta tidies things up.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Force restart on resume from standby
« Reply #7 on: March 28, 2020, 03:14:47 pm »

A minor spelling mistake in the Task setup seems to be a common issue. Check carefully.

Also, I have read that creating a task from scratch can see the task fail, but if you have the task working on one PC and not another, you can Export the task from the PC where it is working and Import it into the PC where it isn't working. If you haven't started rebuilding the PC yet, perhaps try that.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

stricko

  • Galactic Citizen
  • ****
  • Posts: 423
Re: Force restart on resume from standby
« Reply #8 on: March 29, 2020, 01:36:18 am »

I had it, it was all working, and then i lost it. :-(
To explain, i'd got the resume commands working fine, but my testing revealed a complication. I was still getting zombie mode sometimes, when i had gone into standby while a file was playing. This seemed to be MC restarting and attempting to continue playing, BEFORE the resume task had started. Even when the server was up and running, the file would begin playing, and only then the resume command would come in.
So logically i reckoned that i needed MC to stop playing as part of going into standby. There is supposedly an event trigger that you can catch during the sleep process, but i couldnt get it to work properly.  I then tried the Hibernate Trigger utility. I set up a batch script to close MC and called it from the utility. And it worked.... For a few glorious minutes i could be playing a file, request standby, Mc would close, and then the system sleeps. On resume, Mc would restart clean and fresh with nothing trying to play.
And then i got cocky. I thought, why not have the shutdown and resume in the Hibernate Trigger utility..... At some point, i think the registry got corrupted, and all of the things that had been working, didnt. So im now restoring windows....
Logged

stricko

  • Galactic Citizen
  • ****
  • Posts: 423
Re: Force restart on resume from standby
« Reply #9 on: March 29, 2020, 09:03:34 am »

Ok, windows rebuilt (again..)

Things looking much better. Its probably very obvious to some, but ive worked out how to use the Hibernate Trigger utility properly. The key is that it doesn't store the requested actions in the registry or anywhere else, they only exist on the utility itself, and, the utility has to be running for them to be visible to the system. So i need to run the utility at start up.
Logged

RoderickGI

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8186
Re: Force restart on resume from standby
« Reply #10 on: March 29, 2020, 06:47:45 pm »

If you trigger a Sleep action, then you should be able to find the Event in the System section of Event Viewer once you wake the PC.

If you use the above information you should be able to trigger a Stop command for MC when the PC goes to Sleep... I think. Similar to above, but just issuing a "mc26.exe /Stop" command. I haven't tried that. There may still be timing issues.

Which Hibernate Trigger utility are you using? While I'm sure it works fine, it does add another moving part to the solution, along with a batch script. I always try to use the core Windows capabilities for this sort of thing, if they work.
Logged
What specific version of MC you are running:MC27.0.27 @ Oct 27, 2020 and updating regularly Jim!                        MC Release Notes: https://wiki.jriver.com/index.php/Release_Notes
What OS(s) and Version you are running:     Windows 10 Pro 64bit Version 2004 (OS Build 19041.572).
The JRMark score of the PC with an issue:    JRMark (version 26.0.52 64 bit): 3419
Important relevant info about your environment:     
  Using the HTPC as a MC Server & a Workstation as a MC Client plus some DLNA clients.
  Running JRiver for Android, JRemote2, Gizmo, & MO 4Media on a Sony Xperia XZ Premium Android 9.
  Playing video out to a Sony 65" TV connected via HDMI, playing digital audio out via motherboard sound card, PCIe TV tuner

stricko

  • Galactic Citizen
  • ****
  • Posts: 423
Re: Force restart on resume from standby
« Reply #11 on: March 30, 2020, 01:51:45 am »

I'm very much like you and like to use Windows core stuff wherever possible. In this case, while I'm still tuning, it's (marginally) quicker to use the trigger and batch files, but I'll take it out if I ever got this finished. You are right, there is a sleep event, in one of the Kernal logs, value 42 if my memory serves. I tried it, but it didn't work first time, so I reverted to the utility. It's simply called Hibernate Trigger, and seems to have been written by someone into Car PCs. It's been around a long time.

http://www.desimonesystems.com/suspendtrigger/

All seems to be working at the moment. The only glitch seems to be that if you issue a MC26 /close command, and MC26 isn't running, it looks like it tries to open it, and fails saying it can't find the library. You see it when you next resume. It's only a problem when I'm doing maintenance, and I'm sure there must be a way of checking that MC26 is running before issuing the command.

Thanks for all your help with this.



 
Logged

stricko

  • Galactic Citizen
  • ****
  • Posts: 423
Re: Force restart on resume from standby
« Reply #12 on: April 22, 2020, 01:59:57 am »

So I've been running with this on 2 htpcs for a while now, and it's nearly  right. But whenever i think it's done, a new little wrinkle appears, the latest being edid issues that covered in a different  thread. So i've gone back to basics, as stated in the title of this thread. Rather than try and fix the various issues that resume/sleep leaves behind, i've changed my resume script to simply issue a full windows restart. Brutal, but clean and effective.

Standby is more complicated. it seems that to issue the command to put the pc into standby you need full access rights, which cannot be assigned to a batch file. But they can be attached to a task. So you create a dummy task, with no triggers. i've then got another little batch file which just manually fires the task. i've then assigned the second script to a hotkey, and remapped the power key on the remote to the hotkey. Simple, i think not.

Of course, all of the standby stuff my be irrelevant given the sledgehammer approach to restart but it was fun working it out.....
Logged
Pages: [1]   Go Up