B4J Question Websocket Not Closing Fully?

LipJ

New Member
Licensed User
Longtime User
Hi, so i've been creating a Websocket server application for a few months and over time have seen a build up of a few websocket related errors that I just can't trace so would be very grateful if anyone could shed light on what might be causing them so I can get to the bottom of it. Most of these errors start happening after the server has been running for over 30 minutes.

on startup:

'java.lang.NullPointerException at anywheresoftware.b4j.object.WebSocketModule$Adapter.onWebSocketText(WebSocketModule.java:121)' - this happens when i start the program when lots of connections are being established within a very short period of time (6-10 per second). This closes that particular connection which is not the end of the world because the devices then reconnect over the next few minutes once trafic has calmed down.

sometimes when it has been connected to a javascript page:

'onWebSocketError: null' - Not sure what this one is but doesn't seem to cause a problem.

'(WebSocketException) org.eclipse.jetty.websocket.api.WebSocketException: RemoteEndpoint unavailable, current state [CLOSING], expecting [OPEN or CONNECTED]' - Once this starts happening on every event call from b4j_ws.js (raiseEvent("...") etc.) The webpage is then rendered useless until i restart the application.

Inorder to try and work around this error when it starts happening I try to close the websocket and invalidate the session so as to start again, this doesn't work and i get one of two errors:

'2018-01-15 11:18:48.668:INFO:eek:ejs.session:pool-1-thread-71: Session node096qmv9v982me16zlfy1crl5ev91 already being invalidated'
or
'java.lang.RuntimeException: java.lang.IllegalStateException at anywheresoftware.b4a.BA.raiseEvent2(BA.java:119)'

I have really tried to look in to this but can't find any information what either message means. The session being already invalidated makes sense however i'm not sure what is invalidating the session in the first place.

TLDR: what does 'IllegalStateException' mean and how can I stop it happening once it happens?
 
Top