B4J Question [SOLVED - OLD ABMMini build][ABMaterial] Mini Template behaving weirdly on Windows 10 Google Chrome

JackKirk

Well-Known Member
Licensed User
Longtime User
EDIT - SEE POST 4 FOR SOLUTION <<<<<<<<< WRONG

EDIT - SEE POST 5 FOR SOLUTION <<<<<<<<<RIGHT

I have installed

[ABMaterial/ABMServer] Mini Template for absolute beginners (update 2022/09/08)​

as per:

https://www.b4x.com/android/forum/t...ginners-update-2022-09-08.117237/#post-733213

If I run it in debug mode it works fine when I use the Microsoft Edge browser with the URL "http://localhost:51042/template", it also disconnects cleanly when I close the browser - see log below:
However if I run it in debug mode and use the Google Chrome browser (on the same PC) it goes into an endless loop, and issues a heap of "java.io.IOException: java.nio.channels.ClosedChannelException" errors when I close the browser - see log below:
I have tried uninstalling/reinstalling Chrome but it made no difference.

I would really like to consider using ABMaterial but this seems to be a big speed hump.

Any suggestions welcome...
 
Last edited:

JackKirk

Well-Known Member
Licensed User
Longtime User
I downloaded the Firefox browser and it works fine also.

I'm ripping what little hair I have left trying to work out why Chrome isn't working - googled myself silly (on Chrome) but nothing fixes it.

Helpppppp...
 
Last edited:
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Digging deeper, I used 7zip to break the classes out of ABMServer.b4xlib, and copied them to ...\ABMMini\Template

I launched ...\ABMMini\Template\Template.b4j then unchecked ABMServer in [Libraries Manager] then made the ABMServer.b4xlib classes available via [Project>Add Existing Modules]

This enabled me to pause ABMApplication in WebSocket_Connected after the statement

Main.server.NavigateToPage(ws, "","./" & InitialPage)

see following:
B4X:
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)   
    Log("Connected")
    ws = WebSocket1

    ABMPageId = ABM.GetPageID(AppPage, Main.server.AppName,ws)
    '----------------------START MODIFICATION 4.00-------------------------------

    If AppPage.WebsocketReconnected Then

        Main.server.NavigateToPage(ws, "", "./")

        Return
    End If

    Dim session As HttpSession = ABM.GetSession(ws, Main.server.SessionMaxInactiveIntervalSeconds) 'ignore
    If session.IsNew Then
        session.Invalidate
        Main.server.NavigateToPage(ws, "", "./")
        Return
    End If
    '----------------------END MODIFICATION 4.00-------------------------------

    ' Prepare the page IMPORTANT!
    AppPage.Prepare   

    ' Run ConnectPage here in ABMApplication
    ConnectPage   


    ' navigate to the first page
    If Main.server.NeedsAuthorization Then
        If session.GetAttribute2("IsAuthorized", "") = "" Then
            AppPage.ShowModalSheet("login")
            Return
        End If
    End If

    Main.server.NavigateToPage(ws, "","./" & InitialPage)
Log(1)    '<<<<<<<<<<pause here
End Sub

I run this in debug mode and launch Chrome in the same PC and give a URL of "localhost:51042/template"

I then let it go thru the "Log(1)" pause several times

While in this paused state - in the Chrome browser I tap the 3 dots in upper right then [More Tools] then [Developer Tools] then [Console] I find entries of the form:

No WebSocket Open ... core.4.97.min.js:45

When I tap on [core.4.97.min.js:45] it opens a window in the [Sources] tab which shows:
B4X:
function b4j_raiseEvent(e, t) {
    if (b4j_ws) {
        document.getElementById("pageconnectedindicator");
        if (b4j_ws.readyState == 3) {
            console.log("No WebSocket Open");
            window.name= "";
            b4j_ws.close();
            location.reload();
            
            //b4j_connect(currentE, e, t);   
            return;
        }
        try {
            1 !== b4j_ws.readyState ? !1 === b4j_closeMessage && ("undefined" == typeof RobustWebSocket ? window.console.error("Server is currently not available.") : window.console.error("Connection is closed. Trying to reconnect."), b4j_closeMessage = !0) : (b4j_closeMessage = !1, b4j_ws.send(JSON.stringify({
                type: "event",
                event: e,
                params: t
            })))
        } catch (e) {
            console.log(e);
        }
    } else {
        console.log("b4j_ws: " + b4j_ws);
    }
}
and points to the statement [console.log("No WebSocket Open");]

I am well and truly out of my paygrade with this....
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
I FOUND THE PROBLEM!!!! - WELL I THOUGHT I DID - SEE NEXT POST

I had to take a step back and let this stew for a while.

It was obvious that the problem was Windows Chrome specific.

I started exploring Windows Chrome releases and found this site:

https://google-chrome.en.uptodown.com/windows/versions

I was on 123.0.6312.59 - released on March 20 2024

Then the penny dropped - this was about the time I started having problems.

Another clue which I didn't consider relevant until now was that I had this all working earlier but just assumed I had stuffed something in Chrome with all the fiddling I was doing.

So I downgraded Chrome to 122.0.6261.128 - released on March 15 2024

And turned automatic Chrome updating off.

And everything works.

THE PROBLEM IS A BUGGY CHROME BUILD

Just to double check I reinstalled Chrome 123.0.6312.59 again - and with no other changes the problem returned.

Judging by the site pointed to earlier in this post it appears that Chrome updates are happening on an approximately weekly basis - and by that timetable another build is imminent. When it happens I will test it and report back here.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…