I use ServerExampleNoMySQL web server app to get connections from websocket clients, for example Chrome extension "Browser WebSocket Client".
The client succeeds to connect to my server when the Server Protocol field("Sec-WebSocket-Protocol") is empty.
When I assign any value to the heder the server outputs with following and doesn't connect:
Waiting for debugger to connect...
Program started.
2023-06-21 10:50:05.443:INFO::main: Logging initialized @740ms to org.eclipse.jetty.util.log.StdErrLog
2023-06-21 10:50:05.580:INFO ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 11.0.1+13
2023-06-21 10:50:05.627:INFO ejs.session:main: DefaultSessionIdManager workerName=node0
2023-06-21 10:50:05.627:INFO ejs.session:main: No SessionScavenger set, using defaults
2023-06-21 10:50:05.629:INFO ejs.session:main: node0 Scavenging every 600000ms
2023-06-21 10:50:05.677:INFO ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@366647c2{/,file:///C:/B4J/Examples/ServerExampleNoMySQL%20(2)/ServerExampleNoMySQL/Objects/www/,AVAILABLE}
2023-06-21 10:50:05.688:INFO ejs.AbstractNCSARequestLog:main: Opened C:\B4J\Examples\ServerExampleNoMySQL (2)\ServerExampleNoMySQL\Objects\logs\b4j-2023_06_21.request.log
2023-06-21 10:50:05.930:INFO ejs.AbstractConnector:main: Started ServerConnector@581ac8a8{HTTP/1.1,[http/1.1]}{0.0.0.0:51052}
2023-06-21 10:50:05.930:INFO ejs.Server:main: Started @1230ms
Emulated network latency: 200ms
Server started
URL: /push/b4a_ws2
Header: abcd
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 anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:119)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:175)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
at b4j.example.main.main(main.java:29)
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)
... 15 more
It doesn't reach to Sub WebSocket_Connected (WebSocket1 As WebSocket)
How to solve the problem?
The client succeeds to connect to my server when the Server Protocol field("Sec-WebSocket-Protocol") is empty.
When I assign any value to the heder the server outputs with following and doesn't connect:
Waiting for debugger to connect...
Program started.
2023-06-21 10:50:05.443:INFO::main: Logging initialized @740ms to org.eclipse.jetty.util.log.StdErrLog
2023-06-21 10:50:05.580:INFO
2023-06-21 10:50:05.627:INFO
2023-06-21 10:50:05.627:INFO
2023-06-21 10:50:05.629:INFO
2023-06-21 10:50:05.677:INFO
2023-06-21 10:50:05.688:INFO
2023-06-21 10:50:05.930:INFO
2023-06-21 10:50:05.930:INFO
Emulated network latency: 200ms
Server started
URL: /push/b4a_ws2
Header: abcd
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 anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:119)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:175)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
at b4j.example.main.main(main.java:29)
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)
... 15 more
It doesn't reach to Sub WebSocket_Connected (WebSocket1 As WebSocket)
How to solve the problem?