I have created a basic service with grpc-gateway. This is what my .proto file looks like
syntax = "proto3";
package health;
option go_package = "github.com/userl/brw/api/health";
import "google/api/annotations.proto";
service Health {
// Sends a greeting
rpc Ping (HealthRequest) returns (HealthReply) {
option (google.api.http) = {
get: "/ping"
};
}
}
// The request message containing the user's name
message HealthRequest {
}
// The response message containing the greetings
message HealthReply {
string message = 1;
}
I generate and start the service with the following code
mux := runtime.NewServeMux()
opts := []grpc.DialOption{grpc.WithInsecure()}
err := pHealth.RegisterHealthHandlerFromEndpoint(ctx, mux, ":3002"), opts)
if err != nil {
log.Fatal(err)
}
http.ListenAndServe(":3001"), mux)
Now when I try to curl command for example on
curl http://localhost:3001/ping
I get the following error
curl: (7) Failed to connect to localhost port 3003: Connection refused
When I tried grpcurl
grpcurl --plaintext localhost:3002 list
I get the following error
failed to dial target host "localhost:3002": dial tcp 127.0.0.1:3002: connect: connection refused
Not sure what is going wrong here or what I need to do.