Skip to content

Commit 83bd7c7

Browse files
clamp connection timeout and fixed the comment (#748)
* clamp connection timeout and fixed the comment * fixed the format with cargo gmt
1 parent f863f6f commit 83bd7c7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

livekit/src/room/participant/local_participant.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ impl LocalParticipant {
740740
// This is set to 7 seconds to account for various relay timeouts and retries in LiveKit Cloud that occur in rare cases
741741

742742
let max_round_trip_latency = Duration::from_millis(7000);
743+
let min_effective_timeout = Duration::from_millis(1000);
743744

744745
if data.payload.len() > MAX_PAYLOAD_BYTES {
745746
return Err(RpcError::built_in(RpcErrorCode::RequestPayloadTooLarge, None));
@@ -760,7 +761,10 @@ impl LocalParticipant {
760761
let id = create_random_uuid();
761762
let (ack_tx, ack_rx) = oneshot::channel();
762763
let (response_tx, response_rx) = oneshot::channel();
763-
let effective_timeout = data.response_timeout - max_round_trip_latency;
764+
let effective_timeout = std::cmp::max(
765+
data.response_timeout.saturating_sub(max_round_trip_latency),
766+
min_effective_timeout,
767+
);
764768

765769
match self
766770
.publish_rpc_request(RpcRequest {

0 commit comments

Comments
 (0)