B4J Library jServer v4.0 - Based on Jetty 11

alwaysbusy

Expert
Licensed User
Longtime User
If I understand correctly, the WebSocket specs
You are correct, that is also what I understand from it. Note that this is probably ABM only as it does some extensive caching to allow connection disruptions where the server caches a Java shadow in case of a re-connection (may be up to an hour later and the user will never notice anything happened). For this cache, the filter solution did work in all cases, except on iOS Safari, where it did not restore the saved state, but always created a new one. It has an effect our users love that is very close to a native app experience, even if they do not have a stable internet connection all the time.

This cache is a spec my boss came up with that probably isn't implemented anywhere else, so jServer itself does exactly what it needs to do. No need for you to look further into this. If it would cause problems, it is something I have to look at in ABM on how to resolve it. But at least I can rule out it has anything to do with the new jetty version
 

ilan

Expert
Licensed User
Longtime User
hi, i dont know if this is the right thread to ask the question but after updating jserver when I run my project and open the browser and inspect it i get an error:

Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
onmessage https://localhost/b4j_ws.js:64
b4j_ws.js:64:23
onmessage https://localhost/b4j_ws.js:64

do we need to update something on the b4j_ws file?

thanx

EDIT:

I also get those errors:

 
Last edited:

alwaysbusy

Expert
Licensed User
Longtime User
I just had a similar problem in my ABM ws file and it seems it needs some extra code because jetty somtimes sends empty Blobs you have to catch before it tries to parse it as Json.

This is the NEW code I've put in mine to resolve this:



Alwaysbusy
 
Last edited:

ilan

Expert
Licensed User
Longtime User
thank you very much @alwaysbusy this solved all errors
 

tchart

Well-Known Member
Licensed User
Longtime User
The previous version will be available for download. You can rename it to jServer3.xml/jar and keep both of them.
So just to confirm, jServer V4 will be the deafult internal library in a future update?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User

Jmu5667

Well-Known Member
Licensed User
Longtime User
Would it be possible to have jServer3 and JServer4 as part of the internal libs going forward in B4J ?
 

prajinpraveen

Active Member
Licensed User
Longtime User
Not sure if i have to create separate threads for these. These are working well on Jserver 3


1. Does not initialize the map
block1:
ConnectedBrowsers = srvr.CreateThreadSafeMap    ' Start a thread safe map of all the connected browsers

2. java.lang.RuntimeException: Method: setPreferProxiedForAddress not found in: org.eclipse.jetty.server.CustomRequestLog
block:
    For Each h As JavaObject In GetHandlers(srvr)
        If GetType(h) = "org.eclipse.jetty.server.handler.RequestLogHandler" Then
            'TO log a actual IP address behind the proxy
            Dim requestLog As JavaObject = h.RunMethod("getRequestLog", Null)
            requestLog.RunMethod("setPreferProxiedForAddress", Array(True))                               
        End If
    Next

3. java.lang.RuntimeException: Object should first be initialized (JavaObject).

block1:
   Dim SessionManager As JavaObject  ' in process globals
    Dim jo As JavaObject = srvr
    SessionManager  = jo.GetFieldJO("context").RunMethodJO("getSessionHandler", Null).RunMethodJO("getSessionIdManager", Null)
    SessionManager.RunMethod("invalidateAll", Array(sessionid))   '>> Error


4.
block2:
        '    Possible log levels are  TRACE, DEBUG, INFO, WARN and ERROR
        inline.RunMethod("setLevel", Array("INFO"))  ' >> ERROR
Sub inline As JavaObject
    Return Me
End Sub


#IF JAVA
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;

public static void setLevel(String LogLevel){
    Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.toLevel(LogLevel));
    }
#End If

' LOG

setting log level INFO
Error occurred on line: 113 (Main)
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:673)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at zms.main.main(main.java:32)
Caused by: java.lang.ClassCastException: class org.eclipse.jetty.logging.JettyLogger cannot be cast to class ch.qos.logback.classic.Logger (org.eclipse.jetty.logging.JettyLogger and ch.qos.logback.classic.Logger are in unnamed module of loader 'app')
    at zms.main.setLevel(main.java:1101)
    ... 20 more

I couldnt test further
 
Last edited:

MichalK73

Well-Known Member
Licensed User
Longtime User
Hey.
When can we expect a new version or fix for ABMaterial with jetty 4.0 ?
 

OliverA

Expert
Licensed User
Longtime User
Cookies are required to use this site. You must accept them to continue using the site. Learn more…