MarkBryanMilligan / LanternPowerMonitor

The Lantern Power Monitor is a Raspberry Pi service, Java Web Service, and Android application that allow you to monitor every electrical breaker in your house, regardless of how many panels or breakers you have.
GNU General Public License v3.0
80 stars 26 forks source link

Reading hub details stalls. daemon.log shows IllegalMonitorStateException #41

Open KevinBenjamin opened 1 year ago

KevinBenjamin commented 1 year ago

I am running your image on a CM4, and I can't get the app to connect with it. When I go to Configure Hubs, it says scanning for hubs, then quickly goes to reading hub details, then back to scanning for hubs. I noticed these lines that seem to get logged on startup:

Nov 17 16:40:03 energy java[595]: Exception in thread "main" java.lang.IllegalMonitorStateException
Nov 17 16:40:03 energy java[595]: #011at java.base/java.lang.Object.wait(Native Method)
Nov 17 16:40:03 energy java[595]: #011at java.base/java.lang.Object.wait(Object.java:328)
Nov 17 16:40:03 energy java[595]: #011at com.lanternsoftware.currentmonitor.MonitorApp.main(MonitorApp.java:305)
MarkBryanMilligan commented 1 year ago

Interesting... I definitely am not synchronizing around that wait call, I kind of wonder how that was ever working. I'll check in a fix and get a new version released for you.

Unfortunately, I doubt this is the cause of your problem. Something is probably going wrong elsewhere in the bluetooth handshake that is making the app exit (and then this error happens on an unexpected exit).

I just recently got a CM4 myself after a year of waiting but I haven't had a chance to play with it yet. I'll see if I can recreate it with mine.

One question, is your phone by chance a Samsung device?

KevinBenjamin commented 1 year ago

Hi Mark. My phone is a Pixel 6. I tried turning off my phone bluetooth and starting the pi, and it creates the same log entries.

MarkBryanMilligan commented 1 year ago

New version here: https://lanternpowermonitor.com/currentmonitor/update/lantern-currentmonitor.jar You can overwrite the one in /opt/currentmonitor on your CM4 and give it a try.

KevinBenjamin commented 1 year ago

Thanks for the quick response Mark. I put in the new jar and the daemon.log didn't show the same entries. However, the app still did the same thing and I found these lines in /opt/currentmonitor/log/log.txt: 2022-11-18 10:15:02,388 ERROR BleAdvertisement - Failed to unregister advertisement org.freedesktop.dbus.errors.NoReply: Message recipient disconnected from message bus without replying at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.freedesktop.dbus.errors.Error.getException(Error.java:157) at org.freedesktop.dbus.errors.Error.throwException(Error.java:187) at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:164) at org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:228) at com.sun.proxy.$Proxy25.UnregisterAdvertisement(Unknown Source) at com.lanternsoftware.currentmonitor.bluetooth.BleAdvertisement.stop(BleAdvertisement.java:44) at com.lanternsoftware.currentmonitor.bluetooth.BleApplication.stop(BleApplication.java:72) at com.lanternsoftware.currentmonitor.BluetoothConfig.stop(BluetoothConfig.java:31) at com.lanternsoftware.currentmonitor.MonitorApp.lambda$main$0(MonitorApp.java:300) at java.base/java.lang.Thread.run(Thread.java:829) 2022-11-18 10:15:02,439 ERROR BleApplication - Failed to unregister application org.freedesktop.dbus.exceptions.DBusExecutionException: Refusing activation, D-Bus is shutting down. at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.freedesktop.dbus.errors.Error.getException(Error.java:157) at org.freedesktop.dbus.errors.Error.throwException(Error.java:187) at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:164) at org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:228) at com.sun.proxy.$Proxy24.UnregisterApplication(Unknown Source) at com.lanternsoftware.currentmonitor.bluetooth.BleApplication.stop(BleApplication.java:73) at com.lanternsoftware.currentmonitor.BluetoothConfig.stop(BluetoothConfig.java:31) at com.lanternsoftware.currentmonitor.MonitorApp.lambda$main$0(MonitorApp.java:300) at java.base/java.lang.Thread.run(Thread.java:829) 2022-11-18 10:15:04,463 INFO PIGPIO - library size: 13520 2022-11-18 10:15:04,473 INFO CurrentMonitor - Power Monitor Service Stopped 2022-11-18 10:15:32,618 INFO MonitorApp - Current Version: 1.1.3