spacemanspiff2007 / HABApp

Easy home automation with MQTT and/or openHAB
Apache License 2.0
54 stars 23 forks source link

High CPU load after MQTT connection lost #443

Open UrsusS opened 3 months ago

UrsusS commented 3 months ago

If the MQTT connection is lost, the CPU load increases a lot. Even if connection is restored, the high load remains. It needs to restart HABApp to drop the level again.

HABApp Version 24.02.0 OpenHAB version 4.1.1 (Release Build)

2024-03-23 12:35:20.006 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:35:21.029 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:35:21.042 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:35:23.057 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:35:23.068 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:35:27.080 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:35:27.088 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:35:35.112 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:35:35.122 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:35:51.136 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:35:51.145 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:36:23.159 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:36:23.168 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:37:11.184 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:37:11.192 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:38:23.208 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:38:23.216 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:40:11.233 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:40:16.247 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:42:58.262 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:43:01.397 [INFO ] [HABApp.connection.mqtt     ] - Disconnected
2024-03-23 12:47:04.413 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-23 12:47:04.430 [INFO ] [HABApp.connection.mqtt     ] - Connection successful
<manual restart of HABApp>
2024-03-24 11:53:02.350 [INFO ] [HABApp                     ] - HABApp Version 24.02.0
2024-03-24 11:53:02.558 [INFO ] [HABApp.connection.mqtt     ] - Connecting to 192.168.43.7:1883
2024-03-24 11:53:02.592 [INFO ] [HABApp.connection.mqtt     ] - Connection successful
2024-03-24 11:53:02.833 [INFO ] [HABApp.connection.openhab  ] - Connected to OpenHAB version 4.1.1 (Release Build)
[2024-03-23 12:25:55,247] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.0>
[2024-03-23 12:26:55,256] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.1>
[2024-03-23 12:27:55,269] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.1>
[2024-03-23 12:28:55,270] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.1>
[2024-03-23 12:29:55,277] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.1>
[2024-03-23 12:30:55,290] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.1>
[2024-03-23 12:31:55,296] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.1>
[2024-03-23 12:32:55,302] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.1>
[2024-03-23 12:33:55,311] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.0>
[2024-03-23 12:34:55,325] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.1>
[2024-03-23 12:35:55,325] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.4>
[2024-03-23 12:36:55,332] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.8>
[2024-03-23 12:37:55,335] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.9>
[2024-03-23 12:38:55,342] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.0>
[2024-03-23 12:39:55,359] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.0>
[2024-03-23 12:40:55,366] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.0>
[2024-03-23 12:41:55,381] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.0>
[2024-03-23 12:42:55,397] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.0>
[2024-03-23 12:43:55,402] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.0>
[2024-03-23 12:44:55,413] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.0>
[2024-03-23 12:45:55,434] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.0>
[2024-03-23 12:46:55,438] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 0.9>
[2024-03-23 12:47:55,447] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.0>
[2024-03-23 12:48:55,462] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.1>
[2024-03-23 12:49:55,450] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.2>
[2024-03-23 12:50:55,463] [HABApp.EventBus            ]     INFO | num_Server_CPU_Load1: <ItemStateUpdatedEvent name: num_Server_CPU_Load1, value: 1.1>

Please not that the data shown in the graph is transferred over that MQTT connection, so there is a gap while the connection is lost. grafik

spacemanspiff2007 commented 3 months ago

Do you observe this issue without rules or can you provide a minimal working example that shows that behavior? I'll try to reproduce this issue in the meantime.

UrsusS commented 3 months ago

I tried to reproduce that behavior but did not succeed so far. But I can say that I've seen it already several times.

Here is an example, what my rules do: the just publish sometimes some data to the main server. There are four rules which do similar things. ups.zip

There is one rule which sends data with a higher frequency, but that was deactivated when that problem occurred.

The configuration is nothing special:

mqtt:
  connection:
    identifier: HABApp_Zunge # ClientId that is used to uniquely identify this client on the mqtt broker.
    host: '192.168.43.7'     # Connect to this host. Empty string ("") disables the connection.
    port: 1883
    user: 'xxx'
    password: 'xyz'
    tls:
      enabled: false   # Enable TLS for the connection
      ca cert: .       # Path to a CA certificate that will be treated as trusted
      insecure: true   # Validate server hostname in server certificate
  subscribe:
    qos: 0   # Default QoS for subscribing
    topics:
    - - '#'
      -
  publish:
    qos: 0         # Default QoS when publishing values
    retain: false  # Default retain flag when publishing values
  general:
    listen_only: false   # If True HABApp does not publish any value to the broker