B4J Question Web Socket Session.MaxInactiveInterval Problem

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
I have a problem since I'm using B4J 9.80.
Having a web socket server running, on WebSocket_Connected I do:
B4X:
Private Sub WebSocket_Connected(WebSocket1 As WebSocket)
    ws = WebSocket1
    ws.Session.MaxInactiveInterval = 3600 * 24
    ws.RunFunction("ServerReady",Null)
    LastPingTime = DateTime.Now
End Sub
Since v9.80, when a new connection establishes, the line
B4X:
ws.Session.MaxInactiveInterval = 3600 * 24
produces the following error:
B4X:
java.lang.RuntimeException: Object should first be initialized (HttpSession).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:49)
    at anywheresoftware.b4j.object.HttpSessionWrapper.setMaxInactiveInterval(HttpSessionWrapper.java:102)
    at b4j.example.pushscanner._websocket_connected(pushscanner.java:166)
    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.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    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:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at anywheresoftware.b4j.object.WebSocketModule$Adapter$ThreadHandler.run(WebSocketModule.java:204)
    at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
    at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
    at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:121)
    at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:180)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
    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:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at b4j.example.main.main(main.java:29)
Is there any relevant change to the websocket lib?
 

jahswant

Well-Known Member
Licensed User
Longtime User
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
Thank you @Erel and @jahswant for your responses!
I have tried the workaround but I don't use web sockets to run a web application! I make only a socket connection of some clients to the server for data transfer of a telematics system.
It didn't work but I think I haven't put the b4j_ws.js at the right directory!
Where do I have to put it if my project doesn't have a www structure?
Thank you!
 
Upvote 0
Top