B4J Question [jWebSocketClient] Error as a standalone program [Resolved]

Omar Moreno

Member
Licensed User
Longtime User
IDE: B4J 9.80 (64bit)
Port: 51042 (opened in the firewall)
Java: javaOpenJDK11

Downloaded and tested the Client/Server samples and they work without errors from within the B4J IDE.
The server: ServerExampleNoMySQL (Push Messages Examples - WebSockets)
The client: WebSocketPush
The WebSocketPush client was built as a stand-alone program with the IDE (B4JPackager11 Version 1.40) and when run it generates the following errors:

Client erros:
2022-12-21 07:39:42.003:INFO::JavaFX Application Thread: Logging initialized @1937ms to org.eclipse.jetty.util.log.StdErrLog
WebSocket Closed: 101 Switching Protocols
WebSocket Closed: Shutdown
WebSocket Closed: 101 Switching Protocols
WebSocket Closed: Shutdown

Server errors [jserver]:
2022-12-21 07:34:51.792:INFO :oejs.Server:main: jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 11.0.1+13
2022-12-21 07:34:51.991:INFO :oejss.DefaultSessionIdManager:main: Session workerName=node0
2022-12-21 07:34:52.034:INFO :oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@4803b726{/,file:///D:/0-Empresa/Herramientas/Programacion/B4X/B4J/Programas/Servidor_WEB/ServerExampleNoMySQL/Objects/www/,AVAILABLE}
2022-12-21 07:34:52.098:INFO :oejs.RequestLogWriter:main: Opened D:\0-Empresa\Herramientas\Programacion\B4X\B4J\Programas\Servidor_WEB\ServerExampleNoMySQL\Objects\logs\b4j-2022_12_21.request.log
2022-12-21 07:34:52.688:INFO :oejs.AbstractConnector:main: Started ServerConnector@429bd883{HTTP/1.1, (http/1.1)}{0.0.0.0:51042}
2022-12-21 07:34:52.766:INFO :oejs.Server:main: Started Server@4fb61f4a{STARTING}[11.0.9,sto=0] @1848ms
Server started
java.lang.RuntimeException: java.io.IOException: java.nio.channels.ClosedChannelException
    at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:394)
    at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:202)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.IOException: java.nio.channels.ClosedChannelException
    at org.eclipse.jetty.util.FutureCallback.block(FutureCallback.java:163)
    at org.eclipse.jetty.websocket.common.JettyWebSocketRemoteEndpoint.flush(JettyWebSocketRemoteEndpoint.java:267)
    at anywheresoftware.b4j.object.WebSocket.Flush(WebSocket.java:117)
    at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:392)
    ... 6 more
Caused by: java.nio.channels.ClosedChannelException
    at org.eclipse.jetty.websocket.core.internal.FrameFlusher.<clinit>(FrameFlusher.java:47)
    at org.eclipse.jetty.websocket.core.internal.WebSocketConnection.<init>(WebSocketConnection.java:124)
    at org.eclipse.jetty.websocket.core.internal.WebSocketConnection.<init>(WebSocketConnection.java:86)
    at org.eclipse.jetty.websocket.core.server.internal.AbstractHandshaker.newWebSocketConnection(AbstractHandshaker.java:223)
    at org.eclipse.jetty.websocket.core.server.internal.RFC6455Handshaker.createWebSocketConnection(RFC6455Handshaker.java:100)
    at org.eclipse.jetty.websocket.core.server.internal.AbstractHandshaker.upgradeRequest(AbstractHandshaker.java:143)
    at org.eclipse.jetty.websocket.core.server.internal.HandshakerSelector.upgradeRequest(HandshakerSelector.java:39)
    at org.eclipse.jetty.websocket.core.server.WebSocketMappings.upgrade(WebSocketMappings.java:240)
    at org.eclipse.jetty.websocket.server.JettyWebSocketServlet.service(JettyWebSocketServlet.java:181)
    at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
    at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1630)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:506)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1571)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1375)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:463)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1544)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1297)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
    at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
    at org.eclipse.jetty.server.Server.handle(Server.java:562)
    at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:505)
    at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
    at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:894)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1038)
    ... 1 more

Change the Jserver library to Jserver3 and get a new error:

Server errors [jserver3]:
Server started
onWebSocketError: null
onWebSocketError: null
java.lang.RuntimeException: org.eclipse.jetty.websocket.api.WebSocketException: RemoteEndpoint unavailable, current state [CLOSED], expecting [OPEN or CONNECTED]
        at anywheresoftware.b4j.object.WebSocket.setEvents(WebSocket.java:378)
        at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:186)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
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.setEvents(WebSocket.java:375)
        ... 6 more

It doesn't work when the client is a stand-alone package.

Thank you for your possible answers.
 
Top