Power Scheduler Exception / MP Fails to prevent Standby (1 Viewer)

nyt

Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    Running without the TV server, I get the following error when PowerScheduler tries to prevent standby. Is power scheduler dependent on the tv server functionality?

    The problem I'm seeing is that MediaPortal goes to sleep during playback. I do not see anywhere in the source to prevent this when I looked through.

    I see a function PreventMonitorPowerdown in Win32API but it is never called.

    Code:
    2010-09-21 15:11:00.851896 [Info.][(29)]: PowerScheduler: Keep server alive
    2010-09-21 15:11:08.867355 [Info.][(29)]: Exception   :System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:31457
       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
       --- End of inner exception stack trace ---
    
    Server stack trace: 
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStream)
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
       at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)
    
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at TvEngine.PowerScheduler.Interfaces.IPowerController.UserActivityDetected(DateTime when)
       at MediaPortal.Plugins.Process.PowerScheduler.OnTimerElapsed(Object sender, ElapsedEventArgs e)
    2010-09-21 15:11:08.868355 [Info.][(29)]: Exception   :Unable to connect to the remote server
    2010-09-21 15:11:08.868355 [Info.][(29)]:   site      :Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
    2010-09-21 15:11:08.868355 [Info.][(29)]:   source    :mscorlib
    2010-09-21 15:11:08.869355 [Info.][(29)]:   stacktrace:
    Server stack trace: 
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStream)
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
       at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)
    
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at TvEngine.PowerScheduler.Interfaces.IPowerController.UserActivityDetected(DateTime when)
       at MediaPortal.Plugins.Process.PowerScheduler.OnTimerElapsed(Object sender, ElapsedEventArgs e)
    2010-09-21 15:11:33.874785 [Info.][(28)]: PowerScheduler: Keep server alive
    2010-09-21 15:11:34.435817 [Info.][DirectoryWorker(27)]: SQLiteClient: Closing database: movingpictures.db3
    2010-09-21 15:11:34.449818 [Info.][DirectoryWorker(27)]: SQLiteClient: Closing database: TVSeriesDatabase4.db3
    2010-09-21 15:11:41.902244 [Info.][(28)]: Exception   :System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:31457
       at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
       at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
       at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
       --- End of inner exception stack trace ---
    
    Server stack trace: 
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStream)
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
       at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)
    
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at TvEngine.PowerScheduler.Interfaces.IPowerController.UserActivityDetected(DateTime when)
       at MediaPortal.Plugins.Process.PowerScheduler.OnTimerElapsed(Object sender, ElapsedEventArgs e)
    2010-09-21 15:11:41.903244 [Info.][(28)]: Exception   :Unable to connect to the remote server
    2010-09-21 15:11:41.903244 [Info.][(28)]:   site      :Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
    2010-09-21 15:11:41.904244 [Info.][(28)]:   source    :mscorlib
    2010-09-21 15:11:41.904244 [Info.][(28)]:   stacktrace:
    Server stack trace: 
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStream)
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
       at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)
    
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at TvEngine.PowerScheduler.Interfaces.IPowerController.UserActivityDetected(DateTime when)
       at MediaPortal.Plugins.Process.PowerScheduler.OnTimerElapsed(Object sender, ElapsedEventArgs e)
    2010-09-21 15:11:53.414903 [Info.][MPMain(1)]: Main: WM_POWERBROADCAST: 4
    2010-09-21 15:11:53.414903 [Info.][MPMain(1)]: Main: Windows is suspending
    2010-09-21 15:11:53.415903 [Info.][MPMain(1)]: Main: Stopping playback
    MediaPortal Version: 1.1
    MediaPortal Skin: xfactor
    Windows Version: windows 7 ultimate 64
    CPU Type: intel E6300 wolfdale 2.8ghz
    HDD: seagate 1.5tb
    Memory: 4gb ddr2 800
    Motherboard: gigabyte h57
    Video Card: ati 5750
    Video Card Driver: 10.9a
    Sound Card: ati hdmi out
    Sound Card AC3:
    Sound Card Driver:
    1. TV Card:
    1. TV Card Type:
    1. TV Card Driver:
    2. TV Card:
    2. TV Card Type:
    2. TV Card Driver:
    3. TV Card:
    3. TV Card Type:
    3. TV Card Driver:
    4. TV Card:
    4. TV Card Type:
    4. TV Card Driver:
    MPEG2 Video Codec: ffdshow
    MPEG2 Audio Codec: ffdshow
    h.264 Video Codec: ffdshow
    Satelite/CableTV Provider:
    HTPC Case:
    Cooling:
    Power Supply:
    Remote: imon
    TV: JVC RS10
    TV - HTPC Connection: hdmi
     

    chemelli

    Retired Team Member
  • Premium Supporter
  • September 28, 2006
    6,159
    2,264
    49
    Milano, Italy
    Home Country
    Italy Italy
    Re: Power Scheduler Exception while preventing standby

    Code:
    private void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
          if (_onTimerElapsedInside)
          {
            return;
          }
          _onTimerElapsedInside = true;
          _timer.Enabled = false;
          try
          {
            LoadSettings();
    
            // check for singleseat or multiseat setup
            if (_settings.GetSetting("SingleSeat").Get<bool>())
            {
              [COLOR="Red"][B]RegisterToRemotePowerScheduler();[/B][/COLOR]
              // tell the tvserver when we detected the real user the last time
              bool dummy = Unattended; // this will update _lastUserTime in case a player was running
              if (RemotePowerControl.Isconnected)
              {
                RemotePowerControl.Instance.UserActivityDetected(_lastUserTime);
              }
            }
            else
            {
              try 
              {
                Log.Info("PowerScheduler: Keep server alive");
                RemotePowerControl.Instance.UserActivityDetected(DateTime.Now);
              }

    Simone
     

    nyt

    Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    Re: Power Scheduler Exception while preventing standby

    Code:
    private void OnTimerElapsed(object sender, ElapsedEventArgs e)
        {
          if (_onTimerElapsedInside)
          {
            return;
          }
          _onTimerElapsedInside = true;
          _timer.Enabled = false;
          try
          {
            LoadSettings();
    
            // check for singleseat or multiseat setup
            if (_settings.GetSetting("SingleSeat").Get<bool>())
            {
              [COLOR="Red"][B]RegisterToRemotePowerScheduler();[/B][/COLOR]
              // tell the tvserver when we detected the real user the last time
              bool dummy = Unattended; // this will update _lastUserTime in case a player was running
              if (RemotePowerControl.Isconnected)
              {
                RemotePowerControl.Instance.UserActivityDetected(_lastUserTime);
              }
            }
            else
            {
              try 
              {
               [COLOR="Magenta"] Log.Info("PowerScheduler: Keep server alive");[/COLOR]
                RemotePowerControl.Instance.UserActivityDetected(DateTime.Now);
              }

    Simone

    Judging by the log output of "PowerScheduler: Keep server alive" the singleseat code there isn't run.

    Also, all of this code seems to rely on RemotePowerControl, which connects to localhost on 31457. However, the only place I see a bind for that is in TvEngine.PowerScheduler.PowerScheduler (TvEngine3\TVLibrary\Plugins\PowerScheduler). This code will never work without TVservice.

    Is there another way that MP tries to keep itself from being suspended that may not be working, or is that it?
     

    arion_p

    Retired Team Member
  • Premium Supporter
  • February 7, 2007
    3,373
    1,626
    Athens
    Home Country
    Greece Greece
    As it is right now, MP can only use internal PowerSchedulerClient plugin to manage power state. Windows' power settings should be disabled. I know that in the past there have been attempts to use Windows' power settings to suspend the system, but from what I read there have always been issues with it. That is why it was abandoned and PowerScheduler plugin was created. I have not seen the code before PS plugin so I do not know if there was something wrong with it that caused the issues. But with PS plugin instead of Windows power settings it works regardless of TV Server being installed or not.

    Still there is an issue here that PS client plugin unnecessarily logs these errors and that should be fixed (actually it is quite easy)
     

    nyt

    Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    As it is right now, MP can only use internal PowerSchedulerClient plugin to manage power state. Windows' power settings should be disabled. I know that in the past there have been attempts to use Windows' power settings to suspend the system, but from what I read there have always been issues with it. That is why it was abandoned and PowerScheduler plugin was created. I have not seen the code before PS plugin so I do not know if there was something wrong with it that caused the issues. But with PS plugin instead of Windows power settings it works regardless of TV Server being installed or not.

    Still there is an issue here that PS client plugin unnecessarily logs these errors and that should be fixed (actually it is quite easy)

    PS Client isn't actually putting the server into standby. I just have a log full of exceptions, and the htpc never goes to sleep. So, MP doesn't handle windows power events, and it won't put itself to sleep. PS is set to enabled, and I had the timer set to 30m. No joy.

    Code:
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at TvEngine.PowerScheduler.Interfaces.IPowerController.UserActivityDetected(DateTime when)
       at MediaPortal.Plugins.Process.PowerScheduler.OnTimerElapsed(Object sender, ElapsedEventArgs e)
    2010-09-22 18:13:00.744147 [Info.][(28)]: Exception   :Unable to connect to the remote server
    2010-09-22 18:13:00.745147 [Info.][(28)]:   site      :Void HandleReturnMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessage)
    2010-09-22 18:13:00.746147 [Info.][(28)]:   source    :mscorlib
    2010-09-22 18:13:00.747147 [Info.][(28)]:   stacktrace:
    Server stack trace: 
       at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
       at System.Net.HttpWebRequest.GetRequestStream()
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessAndSend(IMessage msg, ITransportHeaders headers, Stream inputStream)
       at System.Runtime.Remoting.Channels.Http.HttpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
       at System.Runtime.Remoting.Channels.SoapClientFormatterSink.SyncProcessMessage(IMessage msg)
     

    nyt

    Retired Team Member
  • Premium Supporter
  • October 15, 2009
    199
    48
    Home Country
    United States of America United States of America
    So, I see two problems with MP and sleep issues.

    1) MP does not prevent standby/sleep/power events during playback. Is there any reason why MP doesn't do this?
    2) power scheduler plugin is split so that it's useless if you're not using TVService.
     

    ronilse

    Retired Team Member
  • Premium Supporter
  • July 19, 2005
    4,422
    283
    Moss
    Home Country
    Norway Norway
    Hi,
    I'll jump onto this & see if I can confirm it within some days.

    Regards
    Roy
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    1) MP does not prevent standby/sleep/power events during playback. Is there any reason why MP doesn't do this?

    MP doesn't support currently letting Windows power management to be used. Missing feature.
     

    Paranoid Delusion

    Moderation Manager
  • Premium Supporter
  • June 13, 2005
    13,062
    2,978
    Cheshire
    Home Country
    United Kingdom United Kingdom
    If this a singleseat setup with no tvserver, then cannot see why you do not use windows settings for power control, same as I do with a singleseat "ForTheRecord" powered tv service, this does not require any of the powerscheduler plugins to be enabled.

    Also just as a side note, both mysleeptimer and Sleepcontrol plugins allow timed shutdown after media has stopped playing, ie my sleeptimer setting is 5 minutes, so when activated it will close MP when video\playlist finished or whatever you set in config after 5 minutes inactivity, and then the M$ power settings kick in, again mine set at 5 minutes then suspend.
     

    Users who are viewing this thread

    Top Bottom