Hi All
I am attempting to build an SSL Web Server to allow B4A clients ('wss' websockets) connect and send and receive data.
I am getting the following error on the server when the B4A client connects:
This is the server code:
WebSocket Class
I have a both project files.
Any help would be appreciated
Regards
John.
I am attempting to build an SSL Web Server to allow B4A clients ('wss' websockets) connect and send and receive data.
I am getting the following error on the server when the B4A client connects:
B4X:
Waiting for debugger to connect...
Program started.
2018-01-12 08:57:28.039:INFO::main: Logging initialized @553ms to org.eclipse.jetty.util.log.StdErrLog
2018-01-12 08:57:28.193:INFO:oejs.Server:main: jetty-9.4.z-SNAPSHOT
2018-01-12 08:57:28.239:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2018-01-12 08:57:28.239:INFO:oejs.session:main: No SessionScavenger set, using defaults
2018-01-12 08:57:28.241:INFO:oejs.session:main: Scavenging every 660000ms
2018-01-12 08:57:28.249:INFO:oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@193948d{/,file:///C:/Users/John%20Murphy/Documents/B4J/Http2/Objects/www,AVAILABLE}
2018-01-12 08:57:28.255:INFO:oejs.AbstractNCSARequestLog:main: Opened C:\Users\John Murphy\Documents\B4J\Http2\Objects\logs\b4j-2018_01_12.request.log
2018-01-12 08:57:28.270:INFO:oejs.AbstractConnector:main: Started ServerConnector@17fd0e6{HTTP/1.1,[http/1.1]}{0.0.0.0:51041}
2018-01-12 08:57:28.284:INFO:oejus.SslContextFactory:main: x509=X509@1fdc050(jetty,h=[],w=[]) for SslContextFactory@1ce4f0a(file:///C:/Isle%20Systems%20Data/Certs/jetty.keystore,null)
2018-01-12 08:57:28.547:INFO:oejs.AbstractConnector:main: Started ServerConnector@ab0bfb{SSL,[ssl, alpn, h2, http/1.1]}{0.0.0.0:51042}
2018-01-12 08:57:28.547:INFO:oejs.Server:main: Started @1063ms
Emulated network latency: 100ms
2018-01-12 08:57:31.512:WARN:oejut.QueuedThreadPool:qtp2909003-12:
java.lang.NoClassDefFoundError: sun/security/util/LegacyAlgorithmConstraints
at sun.security.ssl.ServerHandshaker.<clinit>(ServerHandshaker.java:117)
at sun.security.ssl.SSLEngineImpl.initHandshaker(SSLEngineImpl.java:480)
at sun.security.ssl.SSLEngineImpl.kickstartHandshake(SSLEngineImpl.java:683)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:829)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.fill(SslConnection.java:653)
at org.eclipse.jetty.server.NegotiatingServerConnection.fill(NegotiatingServerConnection.java:153)
at org.eclipse.jetty.server.NegotiatingServerConnection.onFillable(NegotiatingServerConnection.java:98)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:289)
at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:149)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.io.ManagedSelector$$Lambda$9/14966454.run(Unknown Source)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Thread.java:745)
2018-01-12 08:57:31.513:WARN:oejut.QueuedThreadPool:qtp2909003-12: Unexpected thread death: org.eclipse.jetty.util.thread.QueuedThreadPool$2@1b38acb in qtp2909003{STARTED,8<=10<=200,i=2,q=0}
This is the server code:
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#VirtualMachineArgs: -Xbootclasspath/p:alpn-boot-8.1.11.v20170118.jar
#End Region
Sub Process_Globals
Public srvr As Server
End Sub
Sub AppStart (Args() As String)
srvr.Initialize("")
srvr.AddHandler("/test", "Test", False)
srvr.AddHandler("/ws", "WebSock", False)
' // add filter to redirect all traffic from http to https (optional)
srvr.AddFilter("/*", "HttpsFilter", False)
srvr.Port = 51041 'non ssl
ConfigureSSL(51042)
srvr.Http2Enabled = True
srvr.Start
StartMessageLoop
End Sub
Private Sub ConfigureSSL (SslPort As Int)
' // example of SSL connector configuration
Dim ssl As SslConfiguration
ssl.Initialize
ssl.SetKeyStorePath("C:\Isle Systems Data\Certs", "jetty.keystore") 'path to keystore file
ssl.KeyStorePassword = "************"
ssl.KeyManagerPassword = "************"
srvr.SetSslConfiguration(ssl, SslPort)
End Sub
WebSocket Class
B4X:
'WebSocket class
Sub Class_Globals
Private ws As WebSocket
Private timer1 As Timer
End Sub
Public Sub Initialize
Log("WebSocket Initialize")
End Sub
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
Log("WebSocket_Connected")
ws = WebSocket1
timer1.Initialize("timer1", 1000)
timer1.Enabled = True
End Sub
Sub Timer1_Tick
ws.RunFunction("ServerTime", Array As Object(DateTime.Time(DateTime.Now)))
ws.Flush
End Sub
Sub Device_Message(Params As Map)
Log("Device message: " & Params.Get("message"))
End Sub
Private Sub WebSocket_Disconnected
timer1.Enabled = False
Log("WebSocket_Disconnected")
End Sub
I have a both project files.
Any help would be appreciated
Regards
John.