Getting raspberrypi killed by openhab timeout exceptions

I do run openhab 3.4.3 on my raspberrypi 3.
If it runs for about 2-3 days, I get several timeouts, and openhab and the whole raspberrypi is not responsible till I kill all openhab sessions and reboot.
the first indicator in the openhab.log is an alexa binding, and after that all http binding make timeouts:

2023-05-07 15:25:50.299 [WARN ] [io.openhabcloud.internal.CloudClient] - Socket.IO disconnected: ping timeout
2023-05-07 15:25:50.313 [INFO ] [io.openhabcloud.internal.CloudClient] - Disconnected from the openHAB Cloud service (UUID = 7f...2f, base URL = http://localhost:8181)
2023-05-07 15:26:06.233 [WARN ] [mazonechocontrol.internal.Connection] - Request to url 'https://alexa.amazon.de/api/phoenix/state' fails with unknown error
java.net.NoRouteToHostException: No route to host (Host unreachable)
	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) ~[?:?]
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) ~[?:?]
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) ~[?:?]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403) ~[?:?]
	at java.net.Socket.connect(Socket.java:609) ~[?:?]
	at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:289) ~[?:?]
	at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173) ~[?:?]
	at sun.net.NetworkClient.doConnect(NetworkClient.java:182) ~[?:?]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:474) ~[?:?]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:569) ~[?:?]
	at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:265) ~[?:?]
	at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:372) ~[?:?]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081) ~[?:?]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1367) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1342) ~[?:?]
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:246) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.Connection.makeRequest(Connection.java:640) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.Connection.makeRequestAndReturnString(Connection.java:561) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.Connection.getSmartHomeDeviceStatesJson(Connection.java:1082) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler.updateSmartHomeState(AccountHandler.java:911) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler.lambda$2(AccountHandler.java:167) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
2023-05-07 15:26:06.336 [WARN ] [trol.internal.handler.AccountHandler] - updateSmartHomeState fails with unexpected error
java.net.NoRouteToHostException: No route to host (Host unreachable)
	at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399) ~[?:?]
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242) ~[?:?]
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224) ~[?:?]
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403) ~[?:?]
	at java.net.Socket.connect(Socket.java:609) ~[?:?]
	at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:289) ~[?:?]
	at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173) ~[?:?]
	at sun.net.NetworkClient.doConnect(NetworkClient.java:182) ~[?:?]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:474) ~[?:?]
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:569) ~[?:?]
	at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:265) ~[?:?]
	at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:372) ~[?:?]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081) ~[?:?]
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1367) ~[?:?]
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1342) ~[?:?]
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:246) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.Connection.makeRequest(Connection.java:640) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.Connection.makeRequestAndReturnString(Connection.java:561) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.Connection.getSmartHomeDeviceStatesJson(Connection.java:1082) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler.updateSmartHomeState(AccountHandler.java:911) ~[?:?]
	at org.openhab.binding.amazonechocontrol.internal.handler.AccountHandler.lambda$2(AccountHandler.java:167) ~[?:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:834) [?:?]
2023-05-07 15:26:31.098 [WARN ] [p.internal.http.HttpResponseListener] - Requesting 'https://192.168.1.50/beckhoff/zamg.php' (method='GET', content='null') failed: java.util.concurrent.TimeoutException: Total timeout 3000 ms elapsed
2023-05-07 15:26:55.196 [WARN ] [gram.internal.action.TelegramActions] - Exception occured whilst sending message:java.net.SocketTimeoutException: timeout

I have a rule to determine if my network is going down. (pings). but I don’t want to reboot in such case… I want to prevent such problems.
how can this be done?
Thanks

What is the root cause?
LAN or WAN ?
Try to get access to you pi e.g. monitor and keyboard and look for error messages in the system log file / dmesg.

only in openhab.log the problem with alexa… this causes problems to WAN and LAN connections. I have a rule for ping my inverter, and get notified by telegram.

Tackle the root cause and get your network stable.
If you use a hostname in your rule to ping you can try replacing that by its IP but ultimately the problem is not in openHAB so to fix your problems, you’re looking in the wrong place.
I’d investigate DNS and DHCP setup. Ever-assigning the same IPs to devices on DHCP is a good start.

I found some topics with ALEX Echo Dot Binding if this getting offline to WIFI connection. It can occur because my echo dot has not the best wifi connection.
When the problem occurs, all my network components are accessable, instead from openhab. a simple ping from raspberrypi is also possible.
No info in syslog or dmesg only in openhab.log is represented.
Therefore I think this is a problem of openhab / a specifiic binding in openhab.

If you already know the problem is with WLAN/Wifi is there any option to repair that at least for test ?

ok, i have some interesting infos! I had a power failure exactly at 3:25 p.m.
After that my DHCP Server has gone and the wifi Access Point for Alexa Binding also.
It took about 3minutes getting up the wifi AP and the DHCP server. After that, the problem occured and did not resolve itself.

Log openhab:
2023-05-07 15:26:06.233 [WARN ] [mazonechocontrol.internal.Connection] - Request to url ‘Amazon Anmelden’ fails with unknown error
java.net.NoRouteToHostException: No route to host (Host unreachable)

problem in dmesg found:
[252237.615656] Out of memory: Kill process 14132 (java) score 775 or sacrifice child
[252237.616413] Killed process 14132 (java) total-vm:881684kB, anon-rss:596652kB, file-rss:0kB, shmem-rss:0kB

this is the openhab process…
It restarted itself.

my actual situation:
top - 07:32:27 up 2 days, 23:59, 1 user, load average: 1.17, 1.26, 1.19
Tasks: 129 total, 1 running, 77 sleeping, 0 stopped, 0 zombie
%Cpu(s): 16.6 us, 2.5 sy, 0.0 ni, 80.7 id, 0.2 wa, 0.0 hi, 0.1 si, 0.0 st
KiB Mem : 765604 total, 36084 free, 445420 used, 284100 buff/cache
KiB Swap: 102396 total, 70680 free, 31716 used. 242372 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
15402 openhab 20 0 553912 361824 14840 S 34.7 47.3 51:34.03 java

it’s on a raspberrypi 4. is that a problem ?
actual top gives the following:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
15402 openhab 20 0 578924 387224 14432 S 67.0 50.6 204:32.00 java

thanks
Klaus

Very likely one of your rules or components which is embeded in openHAB causes a memory leak. In such case you need to isolate cause.
Start from disabling everythin but essential stuff and see if memory consumption keeps growing. If not, add another element. Until you find one which causes infinite hunger.

what’s a normal memory Percentage for the openhab java process ? 10percent? Actually I am on 53%.

Percentage will differ depending on hardware you use. OH 3.0.x installations I have are staying with 512 megs (26% of system memory, I do not have xtext rules there). I do have an installation which keeps going with constant consumption of 1300 megs (37% of available memory), however it does not exceed that limit.

If you have pi4 with 8 GB of ram then 50% is far too much. Even with 4 GB its a lot.

Best,
Łukasz

Raspberry Pi 3 Model B Plus Rev 1.3 is my model.

And various settings in Java and OS. Assuming you have swap it’s more likely that any of those is your limit, but you didn’t provide reasonably much information about how you installed your system.

This model comes with 1GB of memory. If your openHAB takes 53% it is around 500 megs, which looks fine to me. Still, if its gets killed with out of memory error it means that it exceeds a limit. Whether it is a JVM memory limit or per process limit set by system - we have to figure out.

I think I am victim of this bug of amazon echo control:

but there is no solution to prevent the out of memory problem