Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a heartbeat to the signalling protocol. #409

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mcottontensor
Copy link
Collaborator

Relevant components:

  • Signalling server
  • Common library
  • Frontend library
  • Frontend UI library
  • Matchmaker
  • Platform scripts
  • SFU

Problem statement:

#34
Sometimes a connection between the frontend and signalling server can be broken with no actual close event. With a heartbeat we would be able to timeout a connection and allow the user to retry.

Solution

This just cleans up the ping/pong behaviour to implement it at the protocol level. If these messages don't come through in an expected amount of time the connection is closed and a special timeout event is fired.

*/
export class SignallingProtocol extends EventEmitter {
static get SIGNALLING_VERSION(): string {
return '1.2.1';
}

static readonly PING_TIMEOUT: number = 30 * 1000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it should be configurable in:

  1. frontend PS code
  2. in SS config

The default seems good, but I can imagine people may have cases where they need it set to other values for some particular reason.

private heartbeatWait(): void {
// non-initiator only.
// starts a timer to wait for heartbeat pings. we give it double the ping time to allow some lag
this.keepalive = setTimeout(this.heartbeatTimeout.bind(this), SignallingProtocol.PING_TIMEOUT * 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as the user can set the value, I feel like it should just timeout to what the users sets, rather than 2*value.

Additionally, I think if the user sets the timeout to zero or a negative value, then no timeout should be set/fired.

Copy link
Contributor

@lukehb lukehb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor changes requested, additionally if we the let the user set the value, there should be a slight docs update on the SS readme page when it mentions all the params.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants