B4J Question [SOLVED] jWebSocketClient - Error during initialization of WebSocketHandler

raphaelcno

Active Member
Licensed User
Longtime User
I'm looking at the jWebSocketClient library.
https://www.b4x.com/android/forum/threads/jwebsocketclient-library.40985/
I have downloaded WebSocketPush.zip and run the application, but I get following error message in the log:

2021-12-22 16:20:50.558:INFO::JavaFX Application Thread: Logging initialized @1270ms to org.eclipse.jetty.util.log.StdErrLog
WebSocket Closed: 404 Not Found
WebSocket Closed: 404 Not Found
WebSocket Closed: 404 Not Found
WebSocket Closed: 404 Not Found
...

2021-12-22 - Test - Does not connect.png


No error messages during compilation:

2021-12-22 - Test - Compile OK.png


It seems like the error occurs when following line is executed:
wsh.Initialize(Me, "wsh")
in Sub Connect in PushService module:

B4X:
Private Sub Connect
    Dim wsh As WebSocketHandler
    wsh.Initialize(Me, "wsh")  ' <<< Error
    wsh.Connect(Main.serverLink)
End Sub

Where does this problem come from?
 

raphaelcno

Active Member
Licensed User
Longtime User
I have now created a new B4J project where I just try to initialize WebSocketClient in AppStart, and I get the same kind of error:

B4X:
#Region Project Attributes 
    #MainFormWidth: 600
    #MainFormHeight: 600 
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private xui As XUI
    Private Button1 As B4XView
    
    Private wsc As WebSocketClient  ' <= jWebSocketClient library version 1.11
    
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    Log("AppStart")
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Layout1")
    MainForm.Show
    
    Log("Before wsc.Initialize")
    wsc.Initialize("wsc")  ' => Error
    Log("After wsc.Initialize")
    
End Sub

Private Sub wsc_TextMessage(msg As String)
    Log("wsc_TextMessage => msg: " & msg)
End Sub

Private Sub wsc_Connected
    Log("wsc_Connected")
End Sub

Private Sub wsc_Closed (Reason As String)
    Log("wsc_Closed")
End Sub

Sub Button1_Click
    xui.MsgboxAsync("Hello World!", "B4X")
End Sub

Logs:

Waiting for debugger to connect...
Program started.
AppStart
Before wsc.Initialize
2021-12-23 06:49:53.260:INFO::JavaFX Application Thread: Logging initialized @974ms to org.eclipse.jetty.util.log.StdErrLog
After wsc.Initialize

Project is attached as ZIP file.

Are there some settings I need to change?
 

Attachments

  • Test_WebSocketClient.zip
    2.2 KB · Views: 122
Upvote 0
Top