Option to disable keep alive for JSON-RPC http transport (#9848)
* Keep alive jsonrpc CLI option. * Update to latest json-rpc. * Keep alive flag.
This commit is contained in:
@@ -467,6 +467,10 @@ usage! {
|
||||
"--no-jsonrpc",
|
||||
"Disable the HTTP JSON-RPC API server.",
|
||||
|
||||
FLAG flag_jsonrpc_no_keep_alive: (bool) = false, or |c: &Config| c.rpc.as_ref()?.keep_alive,
|
||||
"--jsonrpc-no-keep-alive",
|
||||
"Disable HTTP/1.1 keep alive header. Disabling keep alive will prevent re-using the same TCP connection to fire multiple requests, recommended when using one request per connection.",
|
||||
|
||||
ARG arg_jsonrpc_port: (u16) = 8545u16, or |c: &Config| c.rpc.as_ref()?.port.clone(),
|
||||
"--jsonrpc-port=[PORT]",
|
||||
"Specify the port portion of the HTTP JSON-RPC API server.",
|
||||
@@ -1219,6 +1223,7 @@ struct Rpc {
|
||||
server_threads: Option<usize>,
|
||||
processing_threads: Option<usize>,
|
||||
max_payload: Option<usize>,
|
||||
keep_alive: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, PartialEq, Deserialize)]
|
||||
@@ -1676,6 +1681,7 @@ mod tests {
|
||||
// -- API and Console Options
|
||||
// RPC
|
||||
flag_no_jsonrpc: false,
|
||||
flag_jsonrpc_no_keep_alive: false,
|
||||
arg_jsonrpc_port: 8545u16,
|
||||
arg_jsonrpc_interface: "local".into(),
|
||||
arg_jsonrpc_cors: "null".into(),
|
||||
@@ -1958,6 +1964,7 @@ mod tests {
|
||||
server_threads: None,
|
||||
processing_threads: None,
|
||||
max_payload: None,
|
||||
keep_alive: None,
|
||||
}),
|
||||
ipc: Some(Ipc {
|
||||
disable: None,
|
||||
|
||||
@@ -855,6 +855,7 @@ impl Configuration {
|
||||
Some(max) if max > 0 => max as usize,
|
||||
_ => 5usize,
|
||||
},
|
||||
keep_alive: !self.args.flag_jsonrpc_no_keep_alive,
|
||||
};
|
||||
|
||||
Ok(conf)
|
||||
|
||||
@@ -44,6 +44,7 @@ pub struct HttpConfiguration {
|
||||
pub server_threads: usize,
|
||||
pub processing_threads: usize,
|
||||
pub max_payload: usize,
|
||||
pub keep_alive: bool,
|
||||
}
|
||||
|
||||
impl Default for HttpConfiguration {
|
||||
@@ -58,6 +59,7 @@ impl Default for HttpConfiguration {
|
||||
server_threads: 1,
|
||||
processing_threads: 4,
|
||||
max_payload: 5,
|
||||
keep_alive: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,6 +220,7 @@ pub fn new_http<D: rpc_apis::Dependencies>(
|
||||
rpc::RpcExtractor,
|
||||
conf.server_threads,
|
||||
conf.max_payload,
|
||||
conf.keep_alive,
|
||||
);
|
||||
|
||||
match start_result {
|
||||
|
||||
Reference in New Issue
Block a user