B4J Question [ABMaterial] Rasp slows down in all tasks

MbedAndroid

Well-Known Member
Licensed User
Longtime User
I got this situation twice. Only reboot the rasp solves the problem. Also SSH hardly works.

Any idea what may cause this?
B4X:
java.lang.RuntimeException: java.lang.NullPointerException
   at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:378)
   at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:186)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
   at anywheresoftware.b4j.object.WebSocket.sendText(WebSocket.java:107)
   at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:375)
   ... 6 more
Disconnected
Ip: 90.19.74.123
Connected
Waiting for value (29 ms)
Saving the first instance
You must set DebugConsoleEnable in BuildPage() first!
Websocket first connection
java.lang.RuntimeException: java.lang.RuntimeException: org.eclipse.jetty.websocket.api.WebSocketException: RemoteEndpoint unavailable, current state [CLOSED], expecting [OPEN or CONNECTED]
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:119)
   at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
   at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:188)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: org.eclipse.jetty.websocket.api.WebSocketException: RemoteEndpoint unavailable, current state [CLOSED], expecting [OPEN or CONNECTED]
   at anywheresoftware.b4j.object.WebSocket.get(WebSocket.java:120)
   at anywheresoftware.b4j.object.WebSocket.RunFunctionWithResult(WebSocket.java:308)
   at com.ab.abmaterial.ABMaterial.GetBrowserWidthHeight(Unknown Source)
   at b4j.example.abmshared._connectfooterfixed(abmshared.java:308)
   at b4j.example.lightcontrol._connectpage(lightcontrol.java:320)
   at b4j.example.lightcontrol._websocket_connected(lightcontrol.java:953)
   at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
   ... 7 more
Caused by: org.eclipse.jetty.websocket.api.WebSocketException: RemoteEndpoint unavailable, current state [CLOSED], expecting [OPEN or CONNECTED]
   at org.eclipse.jetty.websocket.common.WebSocketSession.getRemote(WebSocketSession.java:411)
   at anywheresoftware.b4j.object.WebSocket.sendText(WebSocket.java:107)
   at anywheresoftware.b4j.object.WebSocket.get(WebSocket.java:117)
   ... 16 more
Disconnected

and another one
B4X:
Waiting for value (4398 ms)
 Finished loading and connecting page
java.util.concurrent.TimeoutException
   at anywheresoftware.b4j.object.WebSocket$SimpleFuture.getValue(WebSocket.java:63)
   at com.ab.abmaterial.ABMTable.GetActiveTableRow(Unknown Source)
   at com.ab.abmaterial.ABMTable.GetActiveRow(Unknown Source)
   at com.ab.abmaterial.ABMTable.RefreshInternal(Unknown Source)
   at com.ab.abmaterial.ABMTable.FirstRunInternal(Unknown Source)
   at com.ab.abmaterial.ABMCell.RunAllFirstRunsInternal(Unknown Source)
   at com.ab.abmaterial.ABMRow.RunAllFirstRunsInternal(Unknown Source)
   at com.ab.abmaterial.ABMContainer.RunAllFirstRunsInternal(Unknown Source)
   at com.ab.abmaterial.ABMCell.RefreshInternalExtra(Unknown Source)
   at com.ab.abmaterial.ABMRow.RefreshInternal(Unknown Source)
   at com.ab.abmaterial.ABMPage.Refresh(Unknown Source)
   at b4j.example.meteopage._connectpage(meteopage.java:579)
   at b4j.example.meteopage._websocket_connected(meteopage.java:1009)
   at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
   at anywheresoftware.b4a.BA.raiseEvent(BA.java:77)
   at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:188)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)
Waiting for value (3565 ms)
Waiting for value (16 ms)
Waiting for value (11 ms)
Waiting for value (84 ms)
Waiting for value (12 ms)
Waiting for value (30 ms)
Waiting for value (16 ms)
MeteoPage1ad14bc8-7426-496d-b633-d873cbcc3e5c
preparing for url refresh
Disconnectedmeteo
Scavenger running... (0 page(s) cached)
Scavenger running... (0 page(s) cached)
Scavenger running... (0 page(s) cached)
Scavenger running... (0 page(s) cached)
Scavenger running... (0 page(s) cached)
Scavenger running... (0 page(s) cached)
Scavenger running... (0 page(s) cached)
Scavenger running... (0 page(s) cached)
Scavenger running... (0 page(s) cached
 
Last edited:

Cableguy

Expert
Licensed User
Longtime User
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
hope's it beter now....

i have some idea that this problem comes when i have the browser open with the page loaded, and after some time the laptop falls down in standby.

But i dont get why raspy gets so slow. Also processes out of the java like SSH
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Which raspi model are you using, how are you connecting to it (direct WiFi, ethernet, router, etc), have you made changes to the raspi's "bios", etc...
Basically we need more info about the setup
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
Pi zero Wifi to router
nothing changed into the bios. Only running the java code
Pi is almost on top of the router, 50cm distance...
it happend last week, exactly the same day of the week. But it was running for months with the same code.
Only the laptop shutted down with this page still open..
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Then you should be able to reproduce it, by opening the page and closing the laptop...
In what consists your raspi app? Can it be that it fails retrieving external info?
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
the java error points to
WebSocketException: RemoteEndpoint unavailable, current state [CLOSED], expecting [OPEN or CONNECTED

so it could be that the socket was open and closed by laptop shutdown...
but why the rasp get's so slow afterwards puzzels me.
All other tasks will have no influences guess. Raspy serves a remote unit through a UDP link. Small packages are send 24/24.
THis works fine for years on multiple units. All same program
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
What are your settings in ABMShared for:

B4X:
Public CacheScavengePeriodSeconds As Int = 15*60 ' 15 minutes ' 10 minutes
Public SessionMaxInactiveIntervalSeconds As Int = 30*60 ' 30 minutes '1*60*24 ' one hour ' -1 = immortal but beware! This means the cache is NEVER emptied!

A disconnection like closing the laptop with the browser should not give a problem (the same happens all the time e.g. if one uses an iPad and it goes in sleep mode with the the browser open).

Are you using a timer somewhere that does something with the webpage?
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
hi
B4X:
    Public CacheScavengePeriodSeconds As Int = 15*60 ' 15 minutes
   Public SessionMaxInactiveIntervalSeconds As Int = 30*60 ' 30 min
i didnt make changes in abmaterial
no timer with the webpage.

This application works now for more than 1 year on 3 devices without this issue. Strangly i got this slow-down issue only on this rasp, but that's the one i monitor many times a day, thus having a browser open on the webpage.

Looking into the logfile i found all good working up to 16.24 yesterday, the moment the errors are printed.
I didnt got any browser acess after this
I hardly could make SSH contact, tried to reboot with sudo shutdown -r now. Pulling the power has more effect.
I'm puzzling what the reason could be that the rasp is so much overloaded.
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
it happens twice now. Both when i was away for some reason, thus after xxx time coming back found laptop off, and the homeautomation freezed.
the time 16.23 was exactly the time i was outdoor and left the laptop on.

(Before i pulled the power i renamed the log for saving)

is it possible that this error printed in the log is also coming from the fact that the rasp was overloaded?
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
printed in the log is also coming from the fact that the rasp was overloaded
So you mean backwards? The overloaded raspberry pi is causing the entry in the log about the disconnected websocket? Weird that it happens around the same time every time.

We have a lot of raspberry pi's in the field running an ABM server (we use it to read handheld scanners real time and ABM is used as a dashboard so in many cases the browser stays open too). And in some cases we have a pi who is a bit wacky too. It looks like not every pi is behaving the same. We don't bother looking for a solution anymore but first try replacing the SD Card (a slightly corrupt one can do strange things to your pi). We have invested in a bit more expensive SD cards (industrial ones) and in most cases we never hear from the client again. If the problem does persist, we do replace the whole pi because the cost of a pi doesn't outweight the cost of the time of a technician.
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
well yes, the other pi's have no problem indeed
First i will connect a battery as a kind of UPS to avoid dip's in the mains. This might happen here now and then.
The issue of the SD card i well known. I only use Sandisk class 4
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
I only use Sandisk class 4
We use Kingston, 32 GB, Class 10:

kingston2.png


Our pi's have a battery connected too, but of lately, we are thinking of not doing it any more as it is just cheaper to do a replace, and those batteries have their issues too: sometimes they seem to hang the pi for no reason when they restart (we do a restart of every pi at midnight every day).

If I find the time, we're planning to do some tests using a mini USB Stick where the software runs on (so the SD Card is just used for the Pi OS) because we think the many read/writes on the SD card are causing the problems and those would be eliminated with the USB stick (more reliable).
 
Upvote 0

MbedAndroid

Well-Known Member
Licensed User
Longtime User
sorry i used Kingston too, justed checked it, but class 4.
for the class issues see: https://github.com/raspberrypi/firmware/issues/397
i got several class 10 defective. After replacing it to class 4 this issue was gone, but you're right, booting from the USB is much better.

Just checked the Router log file, no power dip yesterday. Same to other devices (radio, satellite etc)
Still puzzling why the raspy jumps into a turtle mode.........
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
for the class issues see
It's rather old, but informative. We have very good results with class 10 (Pi 3 B+) but so you see, what works for one, doesn't necessary work for another one :D Crazy Pi's...

It has been an ordeal for us too to find the right combo for the type of app we're running.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
You raised a point a few posts back without even noticing....
How is the pi being powered? A good filtered power brick is essential. If your power line fluctuate or if there is a spike, due to a washing machine starting for example, if the power brick is not good enough it can freeze the without rebooting it
 
Upvote 0
Top