Skip to content

Commit

Permalink
Splice
Browse files Browse the repository at this point in the history
  • Loading branch information
AlastairHolmes committed Dec 8, 2021
1 parent aeeb24f commit e563465
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions client/rpc-servers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,30 @@ mod inner {
cors: Option<&Vec<String>>,
io: RpcHandler<M>,
maybe_max_payload_mb: Option<usize>,
maybe_max_out_buffer_capacity_mb: Option<usize>,
server_metrics: ServerMetrics,
) -> io::Result<ws::Server> {
let rpc_max_payload = maybe_max_payload_mb
let max_payload = maybe_max_payload_mb
.map(|mb| mb.saturating_mul(MEGABYTE))
.unwrap_or(RPC_MAX_PAYLOAD_DEFAULT);
let max_out_buffer_capacity = maybe_max_out_buffer_capacity_mb
.map(|mb| mb.saturating_mul(MEGABYTE))
.unwrap_or(WS_MAX_BUFFER_CAPACITY_DEFAULT);

if max_payload > max_out_buffer_capacity {
log::warn!(
"maximum payload ({}) is more than maximum output buffer ({}) size in ws server, the payload will actually be limited by the buffer size",
max_payload,
max_out_buffer_capacity,
)
}

ws::ServerBuilder::with_meta_extractor(io, |context: &ws::RequestContext| {
context.sender().into()
})
.max_payload(rpc_max_payload)
.max_payload(max_payload)
.max_connections(max_connections.unwrap_or(WS_MAX_CONNECTIONS))
.max_out_buffer_capacity(max_out_buffer_capacity)
.allowed_origins(map_cors(cors))
.allowed_hosts(hosts_filtering(cors.is_some()))
.session_stats(server_metrics)
Expand Down

0 comments on commit e563465

Please sign in to comment.