-
Notifications
You must be signed in to change notification settings - Fork 106
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
base: master
Are you sure you want to change the base?
Conversation
*/ | ||
export class SignallingProtocol extends EventEmitter { | ||
static get SIGNALLING_VERSION(): string { | ||
return '1.2.1'; | ||
} | ||
|
||
static readonly PING_TIMEOUT: number = 30 * 1000; |
There was a problem hiding this comment.
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:
- frontend PS code
- 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
…otocol level was too troublesome.
Relevant components:
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.