HASS.Agent: Bug: Satellite service stops/crashes after an amount of time

I’ve just today switched from IoTLink to HASS Agent to give it a go. I’m having issues getting the Satellite service to remain running as it seems to randomly stop.

I want to use the service to read CPU & GPU load & system state change to HA and to suspend the PC and start an application on command.

I’ve tried various methods of starting the service, from using the agent interface, the services app, and manually starting from the executable in program files. All seem to eventually fail on their own. Have also tried reinstalling the service & rebooting the PC.

The service logs don’t seem to be much help as it appears to start without issue; then stops without log and restarts (i noticed the service is set to restart 2 times before doing nothing after the third crash).

2022-04-15 22:34:39.467 +12:00 [INF] [MAIN] Version: 2022.3.27.0
2022-04-15 22:34:39.490 +12:00 [INF] [MAIN] Service started, initializing ..
2022-04-15 22:34:39.576 +12:00 [INF] [WORKER] Startup completed, commencing execution ..
2022-04-15 22:34:39.578 +12:00 [INF] [SETTINGS] Config storage path: C:\Program Files (x86)\LAB02 Research\HASS.Agent Satellite Service\config
2022-04-15 22:34:39.639 +12:00 [INF] [SETTINGS] Configuration loaded
2022-04-15 22:34:39.642 +12:00 [INF] [SETTINGS] MQTT configuration loaded
2022-04-15 22:34:39.649 +12:00 [INF] Application started. Hosting environment: Production; Content root path: C:\Program Files (x86)\LAB02 Research\HASS.Agent Satellite Service\
2022-04-15 22:34:39.660 +12:00 [INF] [SETTINGS_COMMANDS] Loaded 2 entities
2022-04-15 22:34:44.304 +12:00 [INF] [SETTINGS_SENSORS] Loaded 3 entities
2022-04-15 22:34:44.305 +12:00 [INF] [MQTT] Identifying as device: AIDAN-PC-satellite
2022-04-15 22:34:44.311 +12:00 [INF] [RPCMANAGER] Listening
2022-04-15 22:34:44.312 +12:00 [INF] [MQTT] Connecting ..
2022-04-15 22:34:44.355 +12:00 [INF] [MQTT] Connected
2022-04-15 22:34:46.330 +12:00 [INF] [MQTT] Initial registration completed
2022-04-15 22:38:28.147 +12:00 [INF] [MAIN] Version: 2022.3.27.0
2022-04-15 22:38:28.169 +12:00 [INF] [MAIN] Service started, initializing ..
2022-04-15 22:38:28.257 +12:00 [INF] [WORKER] Startup completed, commencing execution ..
2022-04-15 22:38:28.258 +12:00 [INF] [SETTINGS] Config storage path: C:\Program Files (x86)\LAB02 Research\HASS.Agent Satellite Service\config
2022-04-15 22:38:28.319 +12:00 [INF] [SETTINGS] Configuration loaded
2022-04-15 22:38:28.323 +12:00 [INF] [SETTINGS] MQTT configuration loaded
2022-04-15 22:38:28.330 +12:00 [INF] Application started. Hosting environment: Production; Content root path: C:\Program Files (x86)\LAB02 Research\HASS.Agent Satellite Service\
2022-04-15 22:38:28.340 +12:00 [INF] [SETTINGS_COMMANDS] Loaded 2 entities
2022-04-15 22:38:32.994 +12:00 [INF] [SETTINGS_SENSORS] Loaded 3 entities
2022-04-15 22:38:32.996 +12:00 [INF] [MQTT] Identifying as device: AIDAN-PC-satellite
2022-04-15 22:38:33.001 +12:00 [INF] [MQTT] Connecting ..
2022-04-15 22:38:33.001 +12:00 [INF] [RPCMANAGER] Listening
2022-04-15 22:38:33.046 +12:00 [INF] [MQTT] Connected
2022-04-15 22:38:35.016 +12:00 [INF] [MQTT] Initial registration completed
2022-04-15 22:38:58.269 +12:00 [INF] [SETTINGS] Configuration stored
2022-04-15 22:38:58.270 +12:00 [INF] [SETTINGS] Received MQTT settings stored
2022-04-15 22:38:58.270 +12:00 [INF] [MQTT] Reloading configuration ..
2022-04-15 22:38:58.276 +12:00 [INF] [MQTT] Initializing ..
2022-04-15 22:38:58.276 +12:00 [INF] [MQTT] Identifying as device: AIDAN-PC-satellite
2022-04-15 22:38:58.276 +12:00 [INF] [MQTT] Connecting ..
2022-04-15 22:38:58.312 +12:00 [INF] [MQTT] Connected
2022-04-15 22:39:00.283 +12:00 [INF] [MQTT] Initial registration completed

I have also looked into the agent logs but the errors in there seem rather mundane from log write errors

2022-04-15 21:28:46.329 +12:00 [FTL] [PROGRAM] FirstChanceException: The process cannot access the file 'C:\Users\aidan\AppData\Roaming\HASS.Agent\logs\[2022-04-15] HASS.Agent_20220415_019.log' because it is being used by another process.
System.IO.IOException: The process cannot access the file 'C:\Users\aidan\AppData\Roaming\HASS.Agent\logs\[2022-04-15] HASS.Agent_20220415_019.log' because it is being used by another process.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share)
   at Serilog.Sinks.File.FileSink..ctor(String path, ITextFormatter textFormatter, Nullable`1 fileSizeLimitBytes, Encoding encoding, Boolean buffered, FileLifecycleHooks hooks)
   at Serilog.Sinks.File.RollingFileSink.OpenFile(DateTime now, Nullable`1 minSequence)

To IO operation aborts, likely because I was restarting the agent (there are quite a few variations of these)

2022-04-15 23:18:43.494 +12:00 [FTL] [PROGRAM] FirstChanceException: The I/O operation has been aborted because of either a thread exit or an application request.
System.Net.HttpListenerException (995): The I/O operation has been aborted because of either a thread exit or an application request.
   at System.Net.HttpListener.EndGetContext(IAsyncResult asyncResult)

Upgraded to WIndows 11 before the install if that helps at all.

Any advice on how to further debug this would be appreciated. If you need more info about the setup I should be able to get you what you want.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 34 (20 by maintainers)

Most upvoted comments

Hopefully you got that working!

At this point there’s not much more I can do, so I’m closing this ticket. If librehardwaremonitor release a new version of their library, I’ll let you know here so you can test it 😃

Hey @Aidan-Chey,

It’s been a while (way too long) and still no resposne, so I’m guessing we don’t have to expect an easy fix soon. There is an alternative though. You can download the latest release of LibreHardwareMonitor here:

https://github.com/LibreHardwareMonitor/LibreHardwareMonitor/releases/download/v0.9.0/LibreHardwareMonitor-net472.zip

Then just extract is anywhere. To have it start minimized on boot, make sure to check these options:

image

Afterwards, you can use WMI sensors to pull the data:

Fetch CPU temp from LibreHardwareMonitor

Scope: \\.\ROOT\LibreHardwareMonitor

Query: SELECT value FROM Sensor WHERE Name LIKE "%CPU Core%" AND SensorType = "Temperature"

Fetch CPU temp from LibreHardwareMonitor for AMD

Scope: \\.\ROOT\LibreHardwareMonitor

Query: SELECT value FROM Sensor WHERE Name LIKE "%CPU Package%" AND SensorType = "Temperature"

Fetch GPU temp from LibreHardwareMonitor

Scope: \\.\ROOT\LibreHardwareMonitor

Query: SELECT value FROM Sensor WHERE Name LIKE "%GPU Core%" AND SensorType = "Temperature"

There are a bunch more, let me know if you need help with them. Hopefully this’ll be ok for now.

For starters, this is great, a breakthrough! We could be on CSI or something…

No panic though, it doesn’t have to mean there’s something wrong with your PC’s mem - probably just that the library I’m using (LibreHardwareMonitor) isn’t playing by the rules (or so it seems).

I’m going to take a close look at that part of the code and get back to you.

PS If you want to be sure about your mem, you could always run something like memtest86. You boot into it from a usb drive, and it thoroughly examins every bit.

That sounds interesting! Could you please open an elevated terminal window (one way of doing that is to search for cmd in start, then right-click cmd.exe and select Run as administrator), then navigate to the service’s root folder (cd "C:\Program Files (x86)\LAB02 Research\HASS.Agent Satellite Service") and then enter HASS.Agent.Satellite.Service.exe. That way, when it crashes, you’ll have the output in the console window.

Edit: sorry, I just noticed that’s exactly what you said at the end of your comment 😊

I’ve had a look at the errors, and it’s still a bit fuzzy as to why they occur after a while instead of instantly (or not at all).

Read some reports that these can happen with certain build configurations, so I changed them and redeployed the beta. You can simple run the installer again, no need to uninstall first:

https://github.com/LAB02-Research/HASS.Agent/releases/download/b2022.11.1/HASS.Agent.Installer.exe

If this doesn’t help, I’ll release a build for you with extended debug logging enabled (so it logs before doing anything, that way we can more or less pinpoint when it stopped).

Hey @Aidan-Chey,

Thanks for the extensive bug report! You’re right on all parts; log errors can be ignored, that’s just the logger saying it had to start a new logfile, and the service indeed tries to restart 2 times.

I’ve added the sensors you mentioned and attached a debugger to the service to see if I can reproduce the bug locally (I’m also running W11), otherwise I’ll let you know how we can debug more precise on your end 😃