Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

default ws note #10014

Closed
wants to merge 12 commits into from
2 changes: 1 addition & 1 deletion bin/node/cli/benches/transaction_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase {
rpc_http: None,
rpc_ws: None,
rpc_ipc: None,
rpc_ws_max_connections: None,
rpc_ws_max_connections: 100,
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
Expand Down
6 changes: 3 additions & 3 deletions client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ pub struct RunCmd {
pub ws_port: Option<u16>,

/// Maximum number of WS RPC server connections.
#[structopt(long = "ws-max-connections", value_name = "COUNT")]
pub ws_max_connections: Option<usize>,
#[structopt(long = "ws-max-connections", value_name = "COUNT", default_value = "100")]
pub ws_max_connections: usize,

/// Specify browser Origins allowed to access the HTTP & WS RPC servers.
///
Expand Down Expand Up @@ -375,7 +375,7 @@ impl CliConfiguration for RunCmd {
Ok(self.no_grandpa)
}

fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {
fn rpc_ws_max_connections(&self) -> Result<usize> {
Ok(self.ws_max_connections)
}

Expand Down
4 changes: 2 additions & 2 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
/// Get the RPC websockets maximum connections (`None` if unlimited).
///
/// By default this is `None`.
fn rpc_ws_max_connections(&self) -> Result<Option<usize>> {
Ok(None)
fn rpc_ws_max_connections(&self) -> Result<usize> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs above are incorrect.

Ok(100)
}

/// Get the RPC cors (`None` if disabled)
Expand Down
7 changes: 2 additions & 5 deletions client/rpc-servers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ const MEGABYTE: usize = 1024 * 1024;
/// Maximal payload accepted by RPC servers.
pub const RPC_MAX_PAYLOAD_DEFAULT: usize = 15 * MEGABYTE;

/// Default maximum number of connections for WS RPC servers.
const WS_MAX_CONNECTIONS: usize = 100;

/// The RPC IoHandler containing all requested APIs.
pub type RpcHandler<T> = pubsub::PubSubHandler<T, RpcMiddleware>;

Expand Down Expand Up @@ -168,7 +165,7 @@ pub fn start_ws<
M: pubsub::PubSubMetadata + From<futures::channel::mpsc::UnboundedSender<String>>,
>(
addr: &std::net::SocketAddr,
max_connections: Option<usize>,
max_connections: usize,
cors: Option<&Vec<String>>,
io: RpcHandler<M>,
maybe_max_payload_mb: Option<usize>,
Expand All @@ -183,7 +180,7 @@ pub fn start_ws<
})
.event_loop_executor(tokio_handle)
.max_payload(rpc_max_payload)
.max_connections(max_connections.unwrap_or(WS_MAX_CONNECTIONS))
.max_connections(max_connections)
.allowed_origins(map_cors(cors))
.allowed_hosts(hosts_filtering(cors.is_some()))
.session_stats(server_metrics)
Expand Down
4 changes: 2 additions & 2 deletions client/service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ pub struct Configuration {
pub rpc_ws: Option<SocketAddr>,
/// RPC over IPC binding path. `None` if disabled.
pub rpc_ipc: Option<String>,
/// Maximum number of connections for WebSockets RPC server. `None` if default.
pub rpc_ws_max_connections: Option<usize>,
/// Maximum number of connections for WebSockets RPC server.
pub rpc_ws_max_connections: usize,
/// CORS settings for HTTP & WS servers. `None` if all origins are allowed.
pub rpc_cors: Option<Vec<String>>,
/// RPC methods to expose (by default only a safe subset or all of them).
Expand Down
2 changes: 1 addition & 1 deletion client/service/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ fn node_config<
rpc_http: None,
rpc_ipc: None,
rpc_ws: None,
rpc_ws_max_connections: None,
rpc_ws_max_connections: 100,
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
Expand Down
2 changes: 1 addition & 1 deletion test-utils/test-runner/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn default_config(tokio_handle: Handle, mut chain_spec: Box<dyn ChainSpec>)
rpc_http: None,
rpc_ws: None,
rpc_ipc: None,
rpc_ws_max_connections: None,
rpc_ws_max_connections: 100,
rpc_cors: None,
rpc_methods: Default::default(),
rpc_max_payload: None,
Expand Down