Heartbeat with RaiseEvent not reliable

Hi
I am using Raise Event for heart beat to detect if player is active but there are some problems as after some time I got timeout because the message is not received in time.
I send this event every 1.5 sec. My client has a low timeout requirement and I know that this may result in false positives.
What is your recommendation?
Should i use PhotonViewSerialization

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Eduard,

    What is the problem exactly with using RaiseEvent as a heartbeat?

    There is no perfect solution!
    Only trade-offs, tweaking and optimization until we reached an OKish situation that gives a good enough user experience.
    RaiseEvent not reliable
    You can send reliable events in UDP.
    as after some time I got timeout because the message is not received in time
    so your issue is events arriving late? well in this case you need to update your code to handle this situation better...include other variables then network timestamp of sending vs. arrival: RTT, etc.
    You could also make the timeout value dynamic depending on those factors.

    You can relax the timeout or polling period.
    this may result in false positives
    You can't escape this yes!
    You could add an extra event to ask the actor if he's still active...
    so after a potential timeout of actor X based on the heartbeat logic, the master client (or another actor) can send a special event to actor X and wait for his answer (to confirm he's inactive).

    PhotonViewSerialization uses RaiseEvent internally also.
  • Eduard
    Eduard
    edited February 2020
    Hi @JohnTube
    The game is not to heavy in network messages but after some time without touching anything it detects the timeout. The last timestamp when pong event is received is stored so RTT do not affect the disconnection.
    Your last point is actually a great idea but it adds up to the delay of detecting the disconnection.
    I thought that PhotonStream could resolve that

    Do you think it is a bad practice if I raise events at scale of milliseconds? like 700ms udp?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Do you think it is a bad practice if I raise events at scale of milliseconds? like 700ms udp?
    I think 700ms interval is fine.