B4J Question Custom WebSocket Push Framework Reconnection Problem

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
Some times, it's occuring the following problem:
It is possible to have an internet line problem to my server.
The connections with the tablets, may totally be recovered but there is an option that may will be semi-recovered.
I have noticed that after a server internet disconnection, I may have communication from tablets to server, but the server cannot send anything to tablets!
Do you have any other suggestion?
Is it a good idea to implement an MQTT service?

Thank you in advance...
 
This B4A code will close the connection from the client side if the server didn't send a "pong" message for more than 30 seconds:
Code:
Sub PingTimer_Tick
   'Log("PingTimer_Tick: " & wsh.ws.Connected & ", " & lastServerPong & ", "  & (lastServerPong + 30 * DateTime.TicksPerSecond < DateTime.Now))
   If wsh.ws.Connected = False Then Return
   
   If lastServerPong + 30 * DateTime.TicksPerSecond < DateTime.Now Then
     'Log("Closing connection after 30 seconds of no response")
     wsh.Close
   Else
     Dim m As Map
     m.Initialize
     wsh.SendEventToServer("Device_Ping", m)
   End If
End Sub
Once the connection is closed, a new connection will be made.
 
Upvote 0
Back
Top