Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions livekit/src/room/participant/local_participant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,10 @@ impl LocalParticipant {
}

pub async fn perform_rpc(&self, data: PerformRpcData) -> Result<String, RpcError> {
let max_round_trip_latency = Duration::from_millis(2000);
// Maximum amount of time it should ever take for an RPC request to reach the destination, and the ACK to come back
// This is set to 7 seconds to account for various relay timeouts and retries in LiveKit Cloud that occur in rare cases

let max_round_trip_latency = Duration::from_millis(7000);

if data.payload.len() > MAX_PAYLOAD_BYTES {
return Err(RpcError::built_in(RpcErrorCode::RequestPayloadTooLarge, None));
Expand All @@ -757,14 +760,15 @@ impl LocalParticipant {
let id = create_random_uuid();
let (ack_tx, ack_rx) = oneshot::channel();
let (response_tx, response_rx) = oneshot::channel();
let effective_timeout = data.response_timeout - max_round_trip_latency;

match self
.publish_rpc_request(RpcRequest {
destination_identity: data.destination_identity.clone(),
id: id.clone(),
method: data.method.clone(),
payload: data.payload.clone(),
response_timeout: data.response_timeout,
response_timeout: effective_timeout,
version: 1,
})
.await
Expand Down
2 changes: 1 addition & 1 deletion livekit/src/room/participant/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl Default for PerformRpcData {
destination_identity: Default::default(),
method: Default::default(),
payload: Default::default(),
response_timeout: Duration::from_secs(10),
response_timeout: Duration::from_secs(15),
}
}
}
Expand Down