How to make call to gRPC server over HTTP/1.1 from cURL command or in internet browser

SOWMITHRA KUMAR G M :

I have added below new code in protobuf file and compiled to get the generated grpc_pb files.

service EchoService {
  rpc Echo(EchoMessage) returns (EchoMessage) {
    #-----New code start-----
    option (google.api.http) = {
      post: "/v1/echo"
      body: "*"
    };
    #-----New code end------
  }
}

From cURL command executed below command

curl -X POST -k https://localhost:10000/v1/echo -d '{"Key": "Value"}'

After making above request, not able to get the proper response.

My doubt is, any server side code changes needed to prepare the response to send back to caller? If so, Please suggest me with the code (Java) & also how to make request. If not, how we need to make http request to grpc?

Working example is much appreciated.

Anar Sultanov :

The only way to call a remote procedure is to use a generated gRPC client, which performs all unmarshaling of protobuf messages from the gRPC wire format.

See the example of the implementation of Java client and server in the official documentation.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=94576&siteId=1