grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.62k stars 765 forks source link

`google.protobuf.Empty` request failure #980

Open tampler opened 3 years ago

tampler commented 3 years ago

Hello ! This may be related to #702

I have the following proto:

syntax = "proto3";
import "google/protobuf/empty.proto";

service MoodService {
  rpc checkMood(google.protobuf.Empty) returns (stream MoodResp);
}

message MoodResp {
  enum Mood {
    HAPPY = 0;
    SAD = 1;
  }
  Mood mood = 1;
  string desc = 2;
}

And the Javascript client code:

const { MoodServiceClient } = require("./mood_grpc_web_pb.js");

var client = new MoodServiceClient(
  "http://localhost:8080",
  null,
  null
);

When I'm trying to run this, I'm getting the following error:

    return request.serializeBinary();
                   ^
TypeError: request.serializeBinary is not a function

Setup: Ubuntu 18.04.5 Node v14.14.0 Npm v6.14.8

RohitRox commented 3 years ago

for google.protobuf.Empty, you should use new google_protobuf_empty_pb.Empty (in js) instead of null or empty objects. And you get that via import google_protobuf_empty_pb from 'google-protobuf/google/protobuf/empty_pb.js'

Edgarmejiav commented 2 years ago

for google.protobuf.Empty, you should use new google_protobuf_empty_pb.Empty (in js) instead of null or empty objects. And you get that via import google_protobuf_empty_pb from 'google-protobuf/google/protobuf/empty_pb.js'

this works for me

iliyasali2107 commented 6 months ago

hello every one, I didn't find any answer or discussions about my problem, I am sending empty gRPC request via Postman, and it always responses with Status Code 2, are someone has information about sending empty request via Postman ? please, help me