W wl Well-Known Member Licensed User Longtime User Nov 1, 2016 #1 Hi, When I call a b4j_connect I understand a new instance of the corresponding websocket class is instantiated. When does this instance gets destroyed: is there some kind of timeout ? For example: a websocket gets created (and the WebSocket_Connected is called) but then no call is being made (indefintely) ? Thanks
Hi, When I call a b4j_connect I understand a new instance of the corresponding websocket class is instantiated. When does this instance gets destroyed: is there some kind of timeout ? For example: a websocket gets created (and the WebSocket_Connected is called) but then no call is being made (indefintely) ? Thanks
B billzhan Active Member Licensed User Longtime User Nov 1, 2016 #2 WebSocket_Disconnected is something you are looking for, close DB connections in this sub. This sub may not be called immediately when the connection is broken. Code: Copy Private Sub WebSocket_Disconnected End Sub Upvote 0
WebSocket_Disconnected is something you are looking for, close DB connections in this sub. This sub may not be called immediately when the connection is broken. Code: Copy Private Sub WebSocket_Disconnected End Sub
W wl Well-Known Member Licensed User Longtime User Nov 2, 2016 #3 billzhan said: WebSocket_Disconnected is something you are looking for, close DB connections in this sub. This sub may not be called immediately when the connection is broken. Code: Copy Private Sub WebSocket_Disconnected End Sub Click to expand... Indeed this method is not called when the connection is not propertly closed. For a server running 24/7 I guess there must be something to clean up these dangling connections ? Tx Upvote 0
billzhan said: WebSocket_Disconnected is something you are looking for, close DB connections in this sub. This sub may not be called immediately when the connection is broken. Code: Copy Private Sub WebSocket_Disconnected End Sub Click to expand... Indeed this method is not called when the connection is not propertly closed. For a server running 24/7 I guess there must be something to clean up these dangling connections ? Tx
Erel B4X founder Staff member Licensed User Longtime User Nov 2, 2016 #4 It will be eventually raised. If you want to have more control over it then run a JQuery method with a timer every few seconds. It will cause the logical connection to break if there is no actual connection. Upvote 0
It will be eventually raised. If you want to have more control over it then run a JQuery method with a timer every few seconds. It will cause the logical connection to break if there is no actual connection.
W wl Well-Known Member Licensed User Longtime User Nov 2, 2016 #5 Erel said: It will be eventually raised. If you want to have more control over it then run a JQuery method with a timer every few seconds. It will cause the logical connection to break if there is no actual connection. Click to expand... When the connection drops a timed jquery from the client will never reach the server (and would thus make no difference), but I guess you meant that the server is to check (also with a timer) that a heartbeat was received. If so: that's exactly what I am doing at this moment/ Upvote 0
Erel said: It will be eventually raised. If you want to have more control over it then run a JQuery method with a timer every few seconds. It will cause the logical connection to break if there is no actual connection. Click to expand... When the connection drops a timed jquery from the client will never reach the server (and would thus make no difference), but I guess you meant that the server is to check (also with a timer) that a heartbeat was received. If so: that's exactly what I am doing at this moment/
Erel B4X founder Staff member Licensed User Longtime User Nov 2, 2016 #6 wl said: When the connection drops a timed jquery from the client will never reach the server (and would thus make no difference) Click to expand... It will raise an error that will cause the connection to disconnect. Upvote 0
wl said: When the connection drops a timed jquery from the client will never reach the server (and would thus make no difference) Click to expand... It will raise an error that will cause the connection to disconnect.
B billzhan Active Member Licensed User Longtime User Nov 2, 2016 #7 Add a server side event(which does nothing) in a timer. B4J server will try to send a message. Code: Copy Sub Timer1_tick ws.Eval("null;",Null) ws.flush End sub Last edited: Nov 2, 2016 Upvote 0
Add a server side event(which does nothing) in a timer. B4J server will try to send a message. Code: Copy Sub Timer1_tick ws.Eval("null;",Null) ws.flush End sub
B billzhan Active Member Licensed User Longtime User Nov 2, 2016 #8 Remember to disable the timer Code: Copy Private Sub WebSocket_Disconnected timer1.enable = False End Sub Upvote 0
Remember to disable the timer Code: Copy Private Sub WebSocket_Disconnected timer1.enable = False End Sub
M mindful Active Member Licensed User Nov 2, 2016 #9 billzhan said: Add a server side event(which does nothing) in a timer. B4J server will try to send a message. Code: Copy Sub Timer1_tick ws.Eval("null;",Null) ws.flush End sub Click to expand... I got faster disconnect times using : Code: Copy Sub Timer1_Tick Try Dim browserCheck as Future = ws.EvalWithResult("return null", Null) Dim getValue as Object = browserCheck.Value Log("Client browser reachable") Catch Log("Client browser NOT reachable") End Try End Sub The websocket raises the disconnected event faster in my case ... tested with a timer interval of 10 seconds, connecting from my phone and turning Airplane mode ON. Upvote 0
billzhan said: Add a server side event(which does nothing) in a timer. B4J server will try to send a message. Code: Copy Sub Timer1_tick ws.Eval("null;",Null) ws.flush End sub Click to expand... I got faster disconnect times using : Code: Copy Sub Timer1_Tick Try Dim browserCheck as Future = ws.EvalWithResult("return null", Null) Dim getValue as Object = browserCheck.Value Log("Client browser reachable") Catch Log("Client browser NOT reachable") End Try End Sub The websocket raises the disconnected event faster in my case ... tested with a timer interval of 10 seconds, connecting from my phone and turning Airplane mode ON.