mirror of
https://github.com/vector-im/element-call.git
synced 2026-09-22 22:29:30 +00:00
Adapt delayed leave timings when delegation is available
Splits the config options for the timings of a delayed leave event into two sets: one for when delegation is available (as you can relax the timings and get more stable calls this way), and another for when it's unavailable (as we must continue to gracefully downgrade even after Matrix 2.0 is fully rolled out). This works by bluntly hitting the delegation endpoints without auth before joining to check for a 404.
This commit is contained in:
+55
-33
@@ -24,6 +24,35 @@ export enum MatrixRTCMode {
|
||||
Matrix_2_0 = "matrix_2_0",
|
||||
}
|
||||
|
||||
export interface DelayedLeaveTimings {
|
||||
/**
|
||||
* The delay (in milliseconds) with which delayed leave events are sent.
|
||||
*
|
||||
* If the server receives no keep-alives from the client for any longer than
|
||||
* this duration, it will send the leave event, automatically removing the
|
||||
* user from the call.
|
||||
*/
|
||||
delay_ms?: number;
|
||||
|
||||
/**
|
||||
* How frequently (in milliseconds) the client sends keep-alives to the server
|
||||
* to restart the timer for a delayed leave event. Should be less than
|
||||
* {@link DelayedLeaveTimings.delay_ms}.
|
||||
*/
|
||||
restart_ms?: number;
|
||||
|
||||
/**
|
||||
* The time (in milliseconds) after which we consider a delayed event restart HTTP request to have failed.
|
||||
* Setting this to a lower value will result in more frequent retries, but then we will also give up earlier.
|
||||
*
|
||||
* In the presence of network packet loss (hurting TCP connections), the custom delayedEventRestartLocalTimeoutMs
|
||||
* helps by keeping more delayed event reset candidates in flight,
|
||||
* improving the chances of a successful reset. (its is equivalent to the js-sdk `localTimeout` configuration,
|
||||
* but only applies to calls to the `_unstable_updateDelayedEvent` endpoint with a body of `{action:"restart"}`.)
|
||||
*/
|
||||
restart_timeout_ms?: number;
|
||||
}
|
||||
|
||||
export interface ConfigOptions {
|
||||
/**
|
||||
* The Posthog endpoint to which analytics data will be sent.
|
||||
@@ -184,29 +213,6 @@ export interface ConfigOptions {
|
||||
*/
|
||||
wait_for_key_rotation_ms?: number;
|
||||
|
||||
/**
|
||||
* The duration (in milliseconds) after the most recent keep-alive (delayed leave event restart)
|
||||
* that the server waits before sending the leave MatrixRTC membership event.
|
||||
*/
|
||||
delayed_leave_event_delay_ms?: number;
|
||||
|
||||
/**
|
||||
* The time (in milliseconds) after which we consider a delayed event restart http request to have failed.
|
||||
* Setting this to a lower value will result in more frequent retries but also a higher chance of failiour.
|
||||
*
|
||||
* In the presence of network packet loss (hurting TCP connections), the custom delayedEventRestartLocalTimeoutMs
|
||||
* helps by keeping more delayed event reset candidates in flight,
|
||||
* improving the chances of a successful reset. (its is equivalent to the js-sdk `localTimeout` configuration,
|
||||
* but only applies to calls to the `_unstable_updateDelayedEvent` endpoint with a body of `{action:"restart"}`.)
|
||||
*/
|
||||
delayed_leave_event_restart_local_timeout_ms?: number;
|
||||
|
||||
/**
|
||||
* The time interval (in milliseconds) at which the client sends membership keep-alive
|
||||
* messages to the server by restarting the timer for the delayed leave event.
|
||||
*/
|
||||
delayed_leave_event_restart_ms?: number;
|
||||
|
||||
/**
|
||||
* How long we wait before retrying after a network error on any of the requests.
|
||||
*/
|
||||
@@ -231,9 +237,28 @@ export interface ConfigOptions {
|
||||
* Defaults to the js-sdk default (undefined). Which means that rotation will always happen.
|
||||
*/
|
||||
key_rotation_participant_limit?: number;
|
||||
|
||||
/**
|
||||
* Timing options for delayed leave events, which are used to remove a user
|
||||
* from a call when they lose connection.
|
||||
*/
|
||||
delayed_leave?: DelayedLeaveTimings;
|
||||
|
||||
/**
|
||||
* Timing options for delayed leave events, in cases where the ability to
|
||||
* send the event can be delegated to the SFU.
|
||||
*
|
||||
* We recommend setting {@link DelayedLeaveTimings.delay_ms} >>
|
||||
* {@link sync_disconnect_grace_period_ms} here.
|
||||
*/
|
||||
delegated_delayed_leave?: DelayedLeaveTimings;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ResolvedDelayedLeaveTimings extends DelayedLeaveTimings {
|
||||
delay_ms: number; // Required
|
||||
}
|
||||
|
||||
// Overrides members from ConfigOptions that are always provided by the
|
||||
// default config and are therefore non-optional.
|
||||
export interface ResolvedConfigOptions extends ConfigOptions {
|
||||
@@ -257,19 +282,15 @@ export interface ResolvedConfigOptions extends ConfigOptions {
|
||||
>
|
||||
>;
|
||||
};
|
||||
matrix_rtc_session: {
|
||||
wait_for_key_rotation_ms?: number;
|
||||
delayed_leave_event_delay_ms: number;
|
||||
delayed_leave_event_restart_local_timeout_ms?: number;
|
||||
delayed_leave_event_restart_ms?: number;
|
||||
matrix_rtc_session: ConfigOptions["matrix_rtc_session"] & {
|
||||
network_error_retry_ms: number;
|
||||
membership_event_expiry_ms?: number;
|
||||
key_rotation_participant_limit?: number;
|
||||
delayed_leave: ResolvedDelayedLeaveTimings;
|
||||
delegated_delayed_leave: ResolvedDelayedLeaveTimings;
|
||||
};
|
||||
}
|
||||
|
||||
export const DEFAULT_CONFIG: ResolvedConfigOptions = {
|
||||
sync_disconnect_grace_period_ms: 10000,
|
||||
sync_disconnect_grace_period_ms: 10_000,
|
||||
ssla: "https://static.element.io/legal/element-software-and-services-license-agreement-uk-1.pdf",
|
||||
media_quality: {
|
||||
video_codec: "vp8",
|
||||
@@ -285,7 +306,8 @@ export const DEFAULT_CONFIG: ResolvedConfigOptions = {
|
||||
},
|
||||
},
|
||||
matrix_rtc_session: {
|
||||
delayed_leave_event_delay_ms: 10000,
|
||||
network_error_retry_ms: 1000,
|
||||
network_error_retry_ms: 1_000,
|
||||
delayed_leave: { delay_ms: 18_000, restart_ms: 4_000 },
|
||||
delegated_delayed_leave: { delay_ms: 3_600_000, restart_ms: 300_000 },
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user