Skip to content

Heartbeat Size #9

@ryanhlewis

Description

@ryanhlewis

As far as I can tell using this relay, connections are made and stay alive for approx. 55 seconds before they are deemed "idle" and closed. This is prevented by the use of the heartbeat signal made every five seconds, as seen in your code.

const HEARTBEAT = JSON.stringify({ type: 'Heartbeat' })
this.heartbeat = setInterval(() => socket.send(HEARTBEAT), 5000)

My question is, if this is a relay server and intended to have minimal load and bandwidth between the connections, would it not be better to send off a Heartbeat message as something incredibly short (1 bit?).

It doesn't even have to be proper JSON, as it would simply be ensuring that a connection exists.

The heartbeat receiver and the default unknown data receiver both essentially return the same output:

case 'Heartbeat':        // nothing to do       
this.log('♥')        
break

default:        
break

Am I overthinking this? Is the small bit difference between a "{ type:'Heartbeat' }" string and a 0/1 negligible?
Does the understanding behind knowing a heartbeat signal is being received outweigh the tiny increase in possible performance or bandwidth?

Thanks,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions