ava-labs / avalanche-types-rs

Avalanche primitive types in Rust (experimental)
Other
32 stars 10 forks source link

tonic gRPC client connection is getting closed by GoAway #96

Closed hexfusion closed 1 year ago

hexfusion commented 1 year ago

During testing it was found that the corrutabledb errored from a GOAWAY send from the golang rpcdb gRPC server. Often times this is the result of the gRPC client and server not sharing/honoring the expected keep alive configurations.

Rust gRPC client config

Go gRPC server config

Error

[2023-06-16T05:29:16Z ERROR avalanche_types::subnet::rpc::database::rpcdb::client] get request failed: Status { code: Internal, message: "h2 protocol error: http2 error: connection error received: not a result of an error", source: Some(tonic::transport::Error(Transport, hyper::Error(Http2, Error { kind: GoAway(b"", NO_ERROR, Remote) }))) }
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "closed to avoid possible corruption, init error: h2 protocol error: http2 error: connection error received: not a result of an error" }', subnet/src/vm/mod.rs:1283:35
hexfusion commented 1 year ago

The fix is to ensure we are using the default_client config for rpcdb, which it currently is not.

https://github.com/ava-labs/avalanche-types-rs/blob/09e78f78064984103d2cc01ecddf0b1a628f7ac2/src/subnet/rpc/vm/server.rs#L110

https://github.com/ava-labs/avalanche-types-rs/blob/09e78f78064984103d2cc01ecddf0b1a628f7ac2/src/subnet/rpc/vm/server.rs#L150

richardpringle commented 1 year ago

🎉