b4j_ws.min.js:1 connection is closed. Trying to reconnect.
I keep getting the above from my remote server. Using Chrome browser on my Win 8.1 PC.
(This also happens on my dev laptop with local server).
The site is: http://104.168.173.164:51050/punchclock/
(demo / demo) - user and password
Menu - Configure App, any sub item - Company, Users, Employees....
When the table does not populate (Employees), you can click the pagination arrow and the grid will update but not fully (tool bar is missing in Row 1).
Pressing F5 repeatably is like rolling the dice - maybe you will get lucky.
Any Ideas?
I have implemented the re-connect websocket code as per advised:
B4X:
' class_globals...
Type GuessMyNumberState (Number As Int)
Private state As GuessMyNumberState
' sub...
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
Log("Emp Connected")
ws = WebSocket1
Dim session As HttpSession = ws.UpgradeRequest.GetSession
If session.HasAttribute("state") = False Then
state.Initialize
state.Number = Rnd(1, 101)
session.SetAttribute("state", state) 'sets a reference to the state object.
Log($"Creating new state. Number = ${state.Number}"$)
Else
state = session.GetAttribute("state")
Log($"Reusing previous state. Number = ${state.Number}"$)
End If
If ABMShared.NeedsAuthorization Then
Log(" Needs Autho ")
If ws.Session.GetAttribute2("IsAuthorized", "") = "" Then
Log(" Must Autho")
ABMShared.NavigateToPage(ws, "../")
Return
End If
End If
' connect our page with the websocket
page.SetWebSocket(ws)
Log(" page.SetWebSocket...")
' Prepare the page IMPORTANT!
page.Prepare
UserType = page.ws.Session.GetAttribute2( "UserType", "0")
UserID = page.ws.Session.GetAttribute2("UserID", "0")
UserRows = page.ws.Session.GetAttribute2("UserRows", "0")
Dim SQL As SQL = DBM.GetSQL
Dim users As List = DBM.SQLSelect(SQL, "SELECT UserName, UserRows FROM Users WHERE userId=" & UserID)
If users.Size > 0 Then
Dim user As Map = users.Get(0)
UserName = user.GetDefault("username", "")
UserRows = user.GetDefault("userrows", 5)
If UserRows > 0 Then
iRecs = UserRows
Else
iRecs = 5
End If
Log(" users.Size > 0...")
End If
DBM.CloseSQL(SQL)
page.NavigationBar.Refresh
Log(" page.NavigationBar.Refresh... or not...")
End Sub