B4J Question Help for Error: WebSocketException

billyrudi

Active Member
Licensed User
Longtime User
Hi,
i have the following error closing a webpage while the server is sending data to the client.
The error is the same of the well note in ABMATERIAL.
Can you help me to solve it?
regards Paolo

Waiting for debugger to connect...
Program started.
2017-01-23 17:26:26.192:INFO::main: Logging initialized @3151ms
gen 23, 2017 5:26:26 PM com.mchange.v2.log.MLog <clinit>
INFORMAZIONI: MLog clients using java 1.4+ standard logging.
gen 23, 2017 5:26:27 PM com.mchange.v2.c3p0.C3P0Registry banner
INFORMAZIONI: Initializing c3p0-0.9.2.1 [built 20-March-2013 11:16:28 +0000; debug? true; trace: 10]
2017-01-23 17:26:27.476:INFO:eek:ejs.Server:main: jetty-9.3.z-SNAPSHOT
2017-01-23 17:26:27.694:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@1970963{/,file:///D:/Solar/se/Objects/www/,AVAILABLE}
2017-01-23 17:26:27.704:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened D:\Solar\se\Objects\logs\b4j-2017_01_23.request.log
2017-01-23 17:26:27.903:INFO:eek:ejs.ServerConnector:main: Started ServerConnector@765367{HTTP/1.1,[http/1.1]}{0.0.0.0:443}
2017-01-23 17:26:27.907:INFO:eek:ejs.Server:main: Started @4877ms
Emulated network latency: 100ms
gen 23, 2017 5:26:52 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFORMAZIONI: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 20000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1bqooyy9l1kn74k1spf4so|1333739, debugUnreturnedConnectionStackTraces -> false, descri...
.....
....

Error occurred on line: 1083 (wsImpianto)
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:299)
at anywheresoftware.b4j.object.WebSocket.Flush(WebSocket.java:101)
at b4j.example.wsimpianto._mytimer_tick(wsimpianto.java:3751)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:612)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:229)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.GeneratedMethodAccessor1.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:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:192)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
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:299)
at anywheresoftware.b4j.object.WebSocket.Flush(WebSocket.java:101)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:193)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
java.lang.NullPointerException
at anywheresoftware.b4j.object.WebSocketModule$Adapter$1.run(WebSocketModule.java:126)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
Error occurred on line: 791 (wsImpianto)
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:299)
at anywheresoftware.b4j.object.WebSocket.Flush(WebSocket.java:101)
at anywheresoftware.b4j.object.WebSocketModule$Adapter$1.run(WebSocketModule.java:131)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.ShellBA.startMessageLoop(ShellBA.java:111)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:131)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:301)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:159)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:93)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:90)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:84)
at b4j.example.main.main(main.java:29)
 

mindful

Active Member
Licensed User
@billyrudi you could use :
B4X:
Public Sub RedirectOutput(Dir As String, FileName As String) 'ignore
#If RELEASE
   Dim out As OutputStream = File.OpenOutput(Dir, FileName, False) 'Set to True to append the logs
   Dim ps As JavaObject
   ps.InitializeNewInstance("java.io.PrintStream", Array(out, True, "utf8"))
   Dim jo As JavaObject
   jo.InitializeStatic("java.lang.System")
   jo.RunMethod("setOut", Array(ps))
   jo.RunMethod("setErr", Array(ps))
#End If
End Sub
Run it after srvr.Start like:
B4X:
RedirectOutput(File.DirApp, "logs.txt")
and it will create a logs.txt file where your jar is.

This code is provided by @alwaysbusy with the ABMaterial library.
 
Upvote 0

billyrudi

Active Member
Licensed User
Longtime User
Hi,
this is my log in runtime with the server error.
Erel can you help me to understand how to solve it?
regards Paolo
 

Attachments

  • nohup.zip
    50.1 KB · Views: 336
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
You may have SSL certificate cache issue. If you are using SSL , https://yourdomain.com(say the real ip is 2.3.4.5), once you visit this site with the browser(Chrome on Windows), the certificate will be cached by the browser(the expire time is determined by your setting). After that if you use https://yourdomain.com:987 (port has been changed), the browser will send the cached certificate to the server. This will make the connection closed, and it seems that the server stop to work.

You can test by switching to another browser or use the http://2.3.4.5:987 (ip address instead of domain name), this exception should disappear.

B4X:
2017-01-27 23:20:05.147:WARN:oejh.HttpParser:qtp666641942-17: Illegal character 0x16 in state=START for buffer HeapByteBuffer@3ac7127f[p=1,l=517,c=8192,r=516]={\x16<<<\x03\x01\x02\x00\x01\x00\x01\xFc\x03\x03;\x06\xCeFS6\xA7...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00>>>nsions: permessag...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
2017-01-27 23:20:05.148:WARN:oejh.HttpParser:qtp666641942-17: bad HTTP parsed: 400 Illegal character 0x16 for HttpChannelOverHttp@cfbee54{r=0,c=false,a=IDLE,uri=null}
 
Upvote 0
Top