Skip to content
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

Missing HTTP content-type in responses when service timeout #2090

Open
Manphil opened this issue Dec 5, 2024 · 0 comments
Open

Missing HTTP content-type in responses when service timeout #2090

Manphil opened this issue Dec 5, 2024 · 0 comments

Comments

@Manphil
Copy link

Manphil commented Dec 5, 2024

Bug Report

When Server::builder() set a timeout, and the processing time of a single request exceeds the timeout. The responses recevied by go client are missing HTTP content-type.

Version

Test on 0.12.3, but seems all versions have the same bug.

Platform

Linux

Description

Server sides:
Using the helloworld example

  1. Set timeout at Server::build()
Server::builder()
        .timeout(Duration::from_millis(50))
        .add_service(GreeterServer::new(greeter))
        .serve(addr)
        .await?;
  1. Sleep 10s at say_hello()
    async fn say_hello(
        &self,
        request: Request<HelloRequest>,
    ) -> Result<Response<HelloReply>, Status> {
        println!("Got a request from {:?}", request.remote_addr());

       tokio::time::sleep(std::time::Duration::from_secs(10)).await;

        let reply = hello_world::HelloReply {
            message: format!("Hello {}!", request.into_inner().name),
        };
        Ok(Response::new(reply))
    }

Client sides:
Use grpcurl or grpc-go helloworld client will fails, but uses tonic client seems normal.

  1. Use grpcurl
grpcurl -plaintext -import-path ./proto -proto helloworld.proto [::]:50051 helloworld.Greeter/SayHello

Responses:

ERROR:
  Code: Unknown
  Message: malformed header: missing HTTP content-type
  1. Use tonic client
ERROR=status: Cancelled, message: "Timeout expired", details: [], metadata: MetadataMap { headers: {"date": "Thu, 05 Dec 2024 08:04:52 GMT"} }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant