-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sending error response on exceeding buffer capacity (ws) #626
Comments
Actually, the server will close the connection in this case. Still, it would be nice to override this behavior and send a JSON-RPC response. Here's a simple example to trigger this: extern crate env_logger;
use jsonrpc_ws_server::*;
use jsonrpc_ws_server::jsonrpc_core::*;
const RESPONSE_PAYLOAD_SIZE: usize = 5 * 1024 * 1024;
fn main() {
env_logger::init();
let mut io = IoHandler::new();
io.add_method("small", |_params| {
let payload = (0..10).map(|_| "x").collect::<String>();
Ok(Value::String(payload))
});
io.add_method("large", |_params| {
let payload = (0..RESPONSE_PAYLOAD_SIZE).map(|_| "x").collect::<String>();
Ok(Value::String(payload))
});
let server = ServerBuilder::new(io)
.start(&"0.0.0.0:3030".parse().unwrap())
.expect("Server must start with no issues");
server.wait().unwrap()
} |
Yeah, I think it would be possible to detect that the output buffer is exceeded and send |
I believe this behavior is from the The other option is to estimate the response size in my handler, which is certainly possible but it involves an extra serialization step for a potentially large object so I'd prefer to avoid it if possible. |
I think you are right, https://github.com/paritytech/jsonrpc/blob/master/ws/src/session.rs#L281-#L290) seems where the error is caught.
If the connection is dropped by the transport library it's not much |
Thank you for the information! |
Using the ws server, when the response size exceeds
max_out_buffer_capacity
simply no response is sent. Would it be possible to detect this error and send an error JSON-RPC response in this case?The text was updated successfully, but these errors were encountered: