B4J Question WebSocket in B4J 5.80

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,
I have just updated my B4J IDE to the latest (v5.80).
When I used B4J version 5.51 (the version before I updated) the WebSockets was working fine.
Now with version 5.80 I am seeing an error.
I have created a small demo project to do some testing and the same thing is happening with that.
Here is the code:
Main Module:
B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region
Sub Process_Globals
    Private srvr As Server
End Sub
Sub AppStart (Args() As String)
    srvr.Initialize("srvr")
    srvr.Port = 8888
    srvr.AddWebSocket("/ws", "OnlineSocket")
    srvr.StaticFilesFolder = File.Combine(File.DirApp, "www")
    srvr.Start
    StartMessageLoop
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
OnlineSocket Module:
B4X:
'WebSocket class
Sub Class_Globals
    Private ws As WebSocket
End Sub
Public Sub Initialize
 
End Sub
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
    ws = WebSocket1
End Sub
Private Sub WebSocket_Disconnected
End Sub
The error I get in the IDE is:
Using jServer 2.80.
Am I doing something wrong or has something changed that I am not aware of or is this a bug ?
 
Last edited:

aaronk

Well-Known Member
Licensed User
Longtime User
On my local D:\
I have the project in a folder.

Didn't have any issues until I updated my B4J to version 5.80

FYI.. Should of said, running it on a Virtual Machine on a Mac. Running it under Windows 10.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Try to reinstall B4J.
Just uninstalled B4J, deleted the lib folder from C:\Program Files (x86)\Anywhere Software\B4J\Libraries

Re-installed B4J.

Now my demo project it working.

However my main project is still failing but with a different error. (I can't upload this project to the forum)

Below is what I am getting in my main project..

Error I am getting is:

B4X:
Dim srvr As Server
    srvr.Initialize("srvr")
    srvr.Port = 8888
    srvr.AddWebSocket("/ws", "OnlineSocket")
   
    srvr.StaticFilesFolder = File.Combine(File.DirApp, "www")
    srvr.LogsFileFolder = File.Combine(File.DirApp, "logs")

    Dim err As Map
        err.Initialize
        err.Put(403, "/403.html")
        err.Put(404, "/404.html") 'page not found
        err.Put(405, "/405.html")
        err.Put(500, "/500.html") 'server error
    srvr.SetCustomErrorPages(err)
   
   
    srvr.Start

If I remove the line:
srvr.AddWebSocket("/ws", "OnlineSocket")

then the error doesn't occur.

Also check Objects\src and see whether onlinesocket.java was created.
Yes this is created.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
I worked it out.

Even though I had no lines of code that referenced the jMqttbroker, it still failed. I then in-ticked it from the library list and now it works.

I would of thought if I didn't have any lines of code then it wouldn't include that lib in my project when I compile the app. Looks like it does.

Looks like that lib was causing this issue.

In B4J version 5.51 I was able to have both in the same project. Looks like this has now changed in the new version.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…