Hello
I tried this testcode :
But have errors... see below
I tried this testcode :
test wss:
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private ws As WebSocketClient
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.Show
Dim PagesManager As B4XPagesManager
PagesManager.Initialize(MainForm)
ws.Initialize("ws")
'accept all trust manager
Dim ssl As JavaObject
ssl.InitializeNewInstance("org.eclipse.jetty.util.ssl.SslContextFactory", Array(True))
Dim jo As JavaObject = ws
Dim wsc As JavaObject
wsc.InitializeNewInstance("org.eclipse.jetty.websocket.client.WebSocketClient", Array(ssl))
jo.SetField("wsc", wsc)
ws.Connect("wss://b4x.com:51041/smiley/ws")
'ws.Connect("wss://192.168.4.139:17481")
Wait For ws_Connected
Log("connected")
End Sub
'Template version: B4J-1.0
#Region Delegates
Sub MainForm_FocusChanged (HasFocus As Boolean)
B4XPages.Delegate.MainForm_FocusChanged(HasFocus)
End Sub
Sub MainForm_Resize (Width As Double, Height As Double)
B4XPages.Delegate.MainForm_Resize(Width, Height)
End Sub
Sub MainForm_Closed
B4XPages.Delegate.MainForm_Closed
End Sub
Sub MainForm_CloseRequest (EventData As Event)
B4XPages.Delegate.MainForm_CloseRequest(EventData)
End Sub
Public Sub MainForm_IconifiedChanged (Iconified As Boolean)
B4XPages.Delegate.MainForm_IconifiedChanged(Iconified)
End Sub
#End Region
But have errors... see below
Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
2023-12-19 11:49:43.870:INFO::JavaFX Application Thread: Logging initialized @732ms to org.eclipse.jetty.util.log.StdErrLog
org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:515)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:464)
at org.eclipse.jetty.client.HttpReceiver.abort(HttpReceiver.java:545)
at org.eclipse.jetty.client.HttpReceiver.responseFailure(HttpReceiver.java:436)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.failAndClose(HttpReceiverOverHTTP.java:369)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1476)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:209)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:147)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73)
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133)
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:155)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
at org.eclipse.jetty.io.ssl.SslConnection$2.run(SslConnection.java:136)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:760)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:678)
at java.lang.Thread.run(Thread.java:750)
Caused by: java.io.EOFException: HttpConnectionOverHTTP@265b55bf(l:/192.168.19.20:40450 <-> r:b4x.com/67.227.218.133:51041,closed=false)=>HttpChannelOverHTTP@3ca366cf(exchange=HttpExchange@3a22b50 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@d551e1c(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@7bbe0d26{s=START}],recv=HttpReceiverOverHTTP@5c8c9980(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]<-DecryptedEndPoint@60ba64b3{b4x.com/67.227.218.133:51041<->/192.168.19.20:40450,OPEN,fill=-,flush=-,to=1/0}->HttpConnectionOverHTTP@265b55bf(l:/192.168.19.20:40450 <-> r:b4x.com/67.227.218.133:51041,closed=false)=>HttpChannelOverHTTP@3ca366cf(exchange=HttpExchange@3a22b50 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@d551e1c(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@7bbe0d26{s=START}],recv=HttpReceiverOverHTTP@5c8c9980(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]->SocketChannelEndPoint@58c2a1bd{b4x.com/67.227.218.133:51041<->/192.168.19.20:40450,ISHUT,fill=-,flush=-,to=2/0}{io=0/0,kio=0,kro=1}->SslConnection@20d342de{NEED_WRAP,eio=-1/-1,di=-1}=>HttpConnectionOverHTTP@265b55bf(l:/192.168.19.20:40450 <-> r:b4x.com/67.227.218.133:51041,closed=false)=>HttpChannelOverHTTP@3ca366cf(exchange=HttpExchange@3a22b50 req=TERMINATED/null@null res=PENDING/null@null)[send=HttpSenderOverHTTP@d551e1c(req=QUEUED,snd=COMPLETED,failure=null)[HttpGenerator@7bbe0d26{s=START}],recv=HttpReceiverOverHTTP@5c8c9980(rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]
... 13 more
org.eclipse.jetty.websocket.api.UpgradeException: 0 null
at org.eclipse.jetty.websocket.client.WebSocketUpgradeRequest.onComplete(WebSocketUpgradeRequest.java:522)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:193)
at org.eclipse.jetty.client.ResponseNotifier.notifyComplete(ResponseNotifier.java:185)
at org.eclipse.jetty.client.HttpReceiver.terminateResponse(HttpReceiver.java:464)
at org.eclipse.jetty.client.HttpReceiver.abort(HttpReceiver.java:545)
at org.eclipse.jetty.client.HttpReceiver.responseFailure(HttpReceiver.java:436)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.failAndClose(HttpReceiverOverHTTP.java:369)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:338)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1476)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:209)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:147)
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:73)
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:133)