0

I am trying to create a grpc server streaming endpoint.

Here is my protobuf file

syntax = "proto3";

option go_package = "mirror_streampb";
option java_package = "com.mirror_stream";
option java_outer_classname = "StreamIdsProto";
option java_multiple_files = true;

package mirror_stream;

service StreamIDs {

    rpc ListIDs(ListIDsRequest) returns (stream ListIDsResponse) {}

}

message ListIDsRequest {
    int32 num = 1;
}

message ListIDsResponse {
    int32 num = 1;
    int32 id = 2;
}

And here is my golang implementation for that method. Which only returns some random numbers.

func (s *Server) ListIDs(req *streampb.ListIDsRequest, stream streampb.StreamIDs_ListIDsServer) error {

    for i := int32(0); i < req.Num; i++ {
        resp := &streampb.ListIDsResponse{
            Num: i,
            Id:  int32(rand.Intn(10000000)),
        }
        if err := stream.Send(resp); err != nil {
            return err
        }
    }
    return nil
}

So when I try to call that method, I get this error Failed while making call: code:unknown message:grpc: client streaming protocol violation: get <nil>, want <EOF>

I am not sure why it is coming from and where it is coming from.

Can anyone help me figure this out?

HDS
  • 13
  • 4
  • Server looks ok. What's on the client side? – Burak Serdar Nov 11 '20 at 01:13
  • @BurakSerdar There is no client, I am trying to call it using yab. Something like this `yab myService mirror_stream.StreamIDs/ListIDs -r '{"num":10}' -p localhost:50051` – HDS Nov 11 '20 at 01:34

0 Answers0