Questions tagged [rust-tonic]

37 questions
1
vote
1 answer

Tokio / Tonic - How to fix this error: `self` has lifetime `'life0` but it needs to satisfy a `'static` lifetime requirement

I'm building a gRPC server using Rust and tonic and having some issues with a function that returns the stream. So far, the only examples I've seen conveniently create the tx and rx channels within the function - but this isn't a lot of help if you…
1
vote
1 answer

Rust tonic and prost_types conversion

I'm using tonic framework, a rust grpc server implementation. In the generated rust code from the proto file, I have a struct which has a field: #[prost(message, optional, tag="3")] pub data: ::core::option::Option<::prost_types::Value>, generated…
Noor Thabit
  • 79
  • 2
  • 10
1
vote
2 answers

How to add CORS http header?

I'm trying to make a web app with React in the frontend and Rust as the backend. I thought I'd use gRPC through the Tonic crate, to communicate between the front and back end. But I'm getting the error: Cross-Origin Request Blocked: The Same Origin…
kynnysmatto
  • 3,665
  • 23
  • 29
1
vote
1 answer

How to obtain client certificate used to authenticate in my Rust Tonic service?

In my Rust Tonic setup, I have configured mTLS (mutual TLS) authentication between client and server. Now, I would like to use the data stored in client certificate a) for authorizing access (interceptor) b) use in providing the service (ie. I want…
Petr Kozelka
  • 7,670
  • 2
  • 29
  • 44
1
vote
0 answers

Cannot reconnect to gRPC server after client crashed

I did a lot of research but could not find a solution for my problem with gRPC: Summary; After my swift gRPC client application crashes, no gRPC client can connect to my gRPC Server anymore (see errors below) My Setup: I have a Swift frontend…
Timmy
  • 11
  • 2
0
votes
1 answer

Using a common variable between two services on the same server

I am trying to see if this is the right tool for my use case and playing with some hello worlds. I currently have two proto definitions: helloworld.proto, implementing the service Greeter (with associated messages, the same as in the hellowworld…
Korydween
  • 13
  • 5
0
votes
0 answers

Parse gRPC orginal body with Tonic Prost

I have an original body of a gRPC request that I want to decode to a Protobuf Message using Prost (and probably Tonic). As I see the HTTP body part consist of a grpc-header + protobuf-message. In my case the header is just 5 bytes like 000000003b,…
Igor Artamonov
  • 35,450
  • 10
  • 82
  • 113
0
votes
1 answer

Error using package name as "proto.messages.v1" in .proto with prost, and tonic in rust

I'm new to Rust and trying to create a simple gRPC application. Here is the directory structure: grpc-protobuf ├── Cargo.toml ├── build.rs ├── proto │   ├── hello │   │   └── hello.proto │   └── messages │   └── hello.proto └── src └──…
Gaurav Gahlot
  • 1,583
  • 3
  • 14
  • 19
0
votes
0 answers

Calling a method on an object with Tonic Server after serving

I'm working with Tonic and have a code snippet where I create an RPC service. After serving the service, I want to call a method called init() on the rpc_service object. The problem is that the object gets moved by RpcServiceServer::new, and I can't…
0
votes
1 answer

Import common proto in each crate

I'm using tonic_build. I have this dir structure: - Cargo.toml (workspace) - src - common - Cargo.toml - src - common.proto - crates - players - Cargo.toml - build.rs - src - proto -…
Fred Hors
  • 3,258
  • 3
  • 25
  • 71
0
votes
1 answer

How to run a tonic server in the background for a test

Problem I'm learning about Tonic. I'm trying to write an automated test where I spin up a server in the background, call it via a generated client, and then stop the server. Attempts What I have currently looks like this: //... pub fn build(inv:…
bart-kosmala
  • 931
  • 1
  • 11
  • 20
0
votes
1 answer

Abort tokio task when channel is dropped

I have a gRPC service implemented using tonic which returns a stream of values. This stream is created inside a tokio task and send over to client using a tokio mpsc channel. Problem is that the spawned task which is sending the partial results is…
sveatlo
  • 543
  • 9
  • 27
0
votes
1 answer

Passing database connection to multiple Tonic gRPC services

I am trying to share my SeaORM connection with multiple gRPC services. async fn main() -> Result<(), Box> { let config = config::load(); let conn = connection::get(&config.database).await; let addr =…
Nikk
  • 7,384
  • 8
  • 44
  • 90
0
votes
1 answer

In a Rust Tonic gRPC server, how to close the network connection after receiving a malicious request?

Rust Tonic generates the following interface for a simple "hello-world" application: pub trait HelloworldService: Send + Sync + 'static { async fn sayhello( &self, request: tonic::Request, ) ->…
user3839198
  • 115
  • 1
  • 10