Timeout on websocket send
This commit is contained in:
parent
8519f87f60
commit
c3eb2dbf67
2 changed files with 11 additions and 5 deletions
|
|
@ -9,6 +9,7 @@ use crate::{
|
||||||
errors::{SyncServerError, server_error, unauthenticated_error},
|
errors::{SyncServerError, server_error, unauthenticated_error},
|
||||||
server::auth::auth,
|
server::auth::auth,
|
||||||
};
|
};
|
||||||
|
use crate::consts::WEBSOCKET_SEND_TIMEOUT;
|
||||||
|
|
||||||
pub struct AuthenticatedWebSocketHandshake {
|
pub struct AuthenticatedWebSocketHandshake {
|
||||||
pub handshake: WebSocketHandshake,
|
pub handshake: WebSocketHandshake,
|
||||||
|
|
@ -49,9 +50,13 @@ pub async fn send_update_over_websocket(
|
||||||
.context("Failed to serialize update")
|
.context("Failed to serialize update")
|
||||||
.map_err(server_error)?;
|
.map_err(server_error)?;
|
||||||
|
|
||||||
sender
|
tokio::time::timeout(
|
||||||
.send(Message::Text(serialized_update))
|
WEBSOCKET_SEND_TIMEOUT,
|
||||||
.await
|
sender.send(Message::Text(serialized_update)),
|
||||||
.context("Failed to send message over websocket")
|
)
|
||||||
.map_err(server_error)
|
.await
|
||||||
|
.context("WebSocket send deadline expired")
|
||||||
|
.map_err(server_error)?
|
||||||
|
.context("Failed to send message over websocket")
|
||||||
|
.map_err(server_error)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ pub const DEFAULT_MAX_CLIENTS_PER_VAULT: usize = 256;
|
||||||
pub const DEFAULT_LOG_DIRECTORY: &str = "logs";
|
pub const DEFAULT_LOG_DIRECTORY: &str = "logs";
|
||||||
pub const DEFAULT_LOG_ROTATION_INTERVAL: Duration = Duration::from_secs(60 * 60 * 24); // 1 day
|
pub const DEFAULT_LOG_ROTATION_INTERVAL: Duration = Duration::from_secs(60 * 60 * 24); // 1 day
|
||||||
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Info;
|
pub const DEFAULT_LOG_LEVEL: LogLevel = LogLevel::Info;
|
||||||
|
pub const WEBSOCKET_SEND_TIMEOUT: Duration = Duration::from_secs(10);
|
||||||
|
|
||||||
pub const DEFAULT_MERGEABLE_FILE_EXTENSIONS: &[&str] = &["md", "txt"];
|
pub const DEFAULT_MERGEABLE_FILE_EXTENSIONS: &[&str] = &["md", "txt"];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue