B4J Question Jetty Server: I cannot understand this error.

hatzisn

Expert
Licensed User
Longtime User
If I load a page with a websocket in a jetty server (11.0.24) that shows some calculations of an app and leave it there to be updated by the timer eventually I get this error when I try to read the value of a hidden field. What is this?. I have enabled the reconnect websocket javascript and in Developer Tools > Console of the browser I see no error. The code breaks there but in the Network Tab of Developer Tools when I see the data of websocket the messages are passing through correctly. Any advice someone?

Error occurred on line: 47 (CalcWS)
java.io.IOException: org.eclipse.jetty.util.StaticException: Closed
at org.eclipse.jetty.util.FutureCallback.block(FutureCallback.java:163)
at org.eclipse.jetty.util.FutureCallback.block(FutureCallback.java:139)
at org.eclipse.jetty.websocket.common.JettyWebSocketRemoteEndpoint.flush(JettyWebSocketRemoteEndpoint.java:234)
at anywheresoftware.b4j.object.WebSocket.Flush(WebSocket.java:117)
at anywheresoftware.b4j.object.WebSocket$SimpleFuture.getValue(WebSocket.java:73)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:117)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:135)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:121)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:183)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:117)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:104)
at anywheresoftware.b4j.object.JServlet.createInstance(JServlet.java:81)
at anywheresoftware.b4j.object.BackgroundWorkersManager$1.run(BackgroundWorkersManager.java:40)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:121)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:183)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167).
......
 
Last edited:

teddybear

Well-Known Member
Licensed User
Based on this log, the WebSocket connection had already been closed when Ws.Flush was called.
If the Ws.Flush is called in the event Timer1_Tick, do you disable the timer in the event WebSocket_Disconnected?
B4X:
Private Sub WebSocket_Disconnected
    timer1.Enabled = False
End Sub
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Thank you both for answering. I use a background worker that handles the DB connection. There is, where the StartMessageLoop is located. When the app is disconnected I already have added the reconnect-websocket.js and I thought that if it reconnects the ws.GetElementByID("hidobj").GetVal.Value will execute correctly, so no timer1.Enabled = False - I just placed it in Try-Catch. I checked it thoroughly today and I cannot reproduce the error at all.
 
Last edited:
Upvote 0
Top