Coder Social home page Coder Social logo

grpc / grpc-web Goto Github PK

View Code? Open in Web Editor NEW
8.5K 194.0 763.0 1.38 MB

gRPC for Web Clients

Home Page: https://grpc.io

License: Apache License 2.0

Makefile 1.00% Shell 4.38% C++ 20.25% JavaScript 52.87% HTML 1.92% Dockerfile 4.40% TypeScript 4.20% Starlark 0.65% Python 5.02% Zig 5.31%
web javascript grpc

grpc-web's Introduction

gRPC Web · npm version

A JavaScript implementation of gRPC for browser clients. For more information, including a quick start, see the gRPC-web documentation.

gRPC-web clients connect to gRPC services via a special proxy; by default, gRPC-web uses Envoy.

In the future, we expect gRPC-web to be supported in language-specific web frameworks for languages such as Python, Java, and Node. For details, see the roadmap.

Streaming Support

gRPC-web currently supports 2 RPC modes:

Client-side and Bi-directional streaming is not currently supported (see streaming roadmap).

Quick Start

Eager to get started? Try the Hello World example. From this example, you'll learn how to do the following:

  • Define your service using protocol buffers
  • Implement a simple gRPC Service using NodeJS
  • Configure the Envoy proxy
  • Generate protobuf message classes and client service stub for the client
  • Compile all the JS dependencies into a static library that can be consumed by the browser easily

Advanced Demo: Browser Echo App

You can also try to run a more advanced Echo app from the browser with a streaming example.

From the repo root directory:

$ docker-compose pull prereqs node-server envoy commonjs-client
$ docker-compose up node-server envoy commonjs-client

Open a browser tab, and visit http://localhost:8081/echotest.html.

To shutdown: docker-compose down.

Runtime Library

The gRPC-web runtime library is available at npm:

$ npm i grpc-web

Code Generator Plugins

(Prerequisite) 1. Protobuf (protoc)

If you don't already have protoc installed, download it first from here and install it on your PATH.

If you use Homebrew (on macOS), you could run:

brew install protobuf

(Prerequisite) 2. Protobuf-javascript (protoc-gen-js)

If you don't have protoc-gen-js installed, download it from protocolbuffers/protobuf-javascript and install it on your PATH.

Or, use the third-party NPM installer:

npm install -g protoc-gen-js

3. Install gRPC-Web Code Generator

You can download the protoc-gen-grpc-web protoc plugin from our release page:

Make sure all executables are discoverable from your PATH.

For example, on MacOS, you can do:

sudo mv protoc-gen-grpc-web-1.5.0-darwin-aarch64 \
    /usr/local/bin/protoc-gen-grpc-web

chmod +x /usr/local/bin/protoc-gen-grpc-web

(Optional) 4. Verify Installations

You can optionally verify the plugins works follwoing our Hello world example:

cd net/grpc/gateway/examples/helloworld

protoc -I=. helloworld.proto \
  --js_out=import_style=commonjs:. \
  --grpc-web_out=import_style=commonjs,mode=grpcwebtext:.

After the command runs successfully, you should now see two new files generated in the current directory. By running:

ls -1 *_pb.js

Installation is successful if you see the following 2 files:

  • helloworld_pb.js # Generated by protoc-gen-js plugin
  • helloworld_grpc_web_pb.js - Generated by gRPC-Web plugin

Client Configuration Options

Typically, you will run the following command to generate the proto messages and the service client stub from your .proto definitions:

protoc -I=$DIR echo.proto \
  --js_out=import_style=commonjs:$OUT_DIR \
  --grpc-web_out=import_style=commonjs,mode=grpcwebtext:$OUT_DIR

You can then use Browserify, Webpack, Closure Compiler, etc. to resolve imports at compile time.

Import Style

import_style=closure: The default generated code has Closure goog.require() import style.

import_style=commonjs: The CommonJS style require() is also supported.

import_style=commonjs+dts: (Experimental) In addition to above, a .d.ts typings file will also be generated for the protobuf messages and service stub.

import_style=typescript: (Experimental) The service stub will be generated in TypeScript. See TypeScript Support below for information on how to generate TypeScript files.

Note: The commonjs+dts and typescript styles are only supported by --grpc-web_out=import_style=..., not by --js_out=import_style=....

Wire Format Mode

For more information about the gRPC-web wire format, see the specification.

mode=grpcwebtext: The default generated code sends the payload in the grpc-web-text format.

  • Content-type: application/grpc-web-text
  • Payload are base64-encoded.
  • Both unary and server streaming calls are supported.

mode=grpcweb: A binary protobuf format is also supported.

  • Content-type: application/grpc-web+proto
  • Payload are in the binary protobuf format.
  • Only unary calls are supported.

How It Works

Let's take a look at how gRPC-web works with a simple example. You can find out how to build, run and explore the example yourself in Build and Run the Echo Example.

1. Define your service

The first step when creating any gRPC service is to define it. Like all gRPC services, gRPC-web uses protocol buffers to define its RPC service methods and their message request and response types.

message EchoRequest {
  string message = 1;
}

...

service EchoService {
  rpc Echo(EchoRequest) returns (EchoResponse);

  rpc ServerStreamingEcho(ServerStreamingEchoRequest)
      returns (stream ServerStreamingEchoResponse);
}

2. Run the server and proxy

Next you need to have a gRPC server that implements the service interface and a gateway proxy that allows the client to connect to the server. Our example builds a simple Node gRPC backend server and the Envoy proxy.

For the Echo service: see the service implementations.

For the Envoy proxy: see the config yaml file.

3. Write your JS client

Once the server and gateway are up and running, you can start making gRPC calls from the browser!

Create your client:

var echoService = new proto.mypackage.EchoServiceClient(
  'http://localhost:8080');

Make a unary RPC call:

var request = new proto.mypackage.EchoRequest();
request.setMessage(msg);
var metadata = {'custom-header-1': 'value1'};
echoService.echo(request, metadata, function(err, response) {
  if (err) {
    console.log(err.code);
    console.log(err.message);
  } else {
    console.log(response.getMessage());
  }
});

Server-side streaming:

var stream = echoService.serverStreamingEcho(streamRequest, metadata);
stream.on('data', function(response) {
  console.log(response.getMessage());
});
stream.on('status', function(status) {
  console.log(status.code);
  console.log(status.details);
  console.log(status.metadata);
});
stream.on('end', function(end) {
  // stream end signal
});

// to close the stream
stream.cancel()

For an in-depth tutorial, see this page.

Setting Deadline

You can set a deadline for your RPC by setting a deadline header. The value should be a Unix timestamp, in milliseconds.

var deadline = new Date();
deadline.setSeconds(deadline.getSeconds() + 1);

client.sayHelloAfterDelay(request, {deadline: deadline.getTime().toString()},
  (err, response) => {
    // err will be populated if the RPC exceeds the deadline
    ...
  });

TypeScript Support

The grpc-web module can now be imported as a TypeScript module. This is currently an experimental feature. Any feedback welcome!

When using the protoc-gen-grpc-web protoc plugin, mentioned above, pass in either:

  • import_style=commonjs+dts: existing CommonJS style stub + .d.ts typings
  • import_style=typescript: full TypeScript output

Do not use import_style=typescript for --js_out, it will silently be ignored. Instead you should use --js_out=import_style=commonjs, or --js_out=import_style=commonjs,binary if you are using mode=grpcweb. The --js_out plugin will generate JavaScript code (echo_pb.js), and the -grpc-web_out plugin will generate a TypeScript definition file for it (echo_pb.d.ts). This is a temporary hack until the --js_out supports TypeScript itself.

For example, this is the command you should use to generate TypeScript code using the binary wire format

protoc -I=$DIR echo.proto \
  --js_out=import_style=commonjs,binary:$OUT_DIR \
  --grpc-web_out=import_style=typescript,mode=grpcweb:$OUT_DIR

It will generate the following files:

  • EchoServiceClientPb.ts - Generated by --grpc-web_out, contains the TypeScript gRPC-web code.
  • echo_pb.js - Generated by --js_out, contains the JavaScript Protobuf code.
  • echo_pb.d.ts - Generated by --grpc-web_out, contains TypeScript definitions for echo_pb.js.

Using Callbacks

import * as grpcWeb from 'grpc-web';
import {EchoServiceClient} from './EchoServiceClientPb';
import {EchoRequest, EchoResponse} from './echo_pb';

const echoService = new EchoServiceClient('http://localhost:8080', null, null);

const request = new EchoRequest();
request.setMessage('Hello World!');

const call = echoService.echo(request, {'custom-header-1': 'value1'},
  (err: grpcWeb.RpcError, response: EchoResponse) => {
    console.log(response.getMessage());
  });
call.on('status', (status: grpcWeb.Status) => {
  // ...
});

(See here full list of possible .on(...) callbacks)

(Option) Using Promises (Limited features)

NOTE: It is not possible to access the .on(...) callbacks (e.g. for metadata and status) when Promise is used.

// Create a Promise client instead
const echoService = new EchoServicePromiseClient('http://localhost:8080', null, null);

... (same as above)

this.echoService.echo(request, {'custom-header-1': 'value1'})
  .then((response: EchoResponse) => {
    console.log(`Received response: ${response.getMessage()}`);
  }).catch((err: grpcWeb.RpcError) => {
    console.log(`Received error: ${err.code}, ${err.message}`);
  });

For the full TypeScript example, see ts-example/client.ts with the instructions to run.

Custom Interceptors

Custom interceptors can be implemented and chained, which could be useful for features like auth, retries, etc.

There are 2 types of interceptors (interfaces):

  • UnaryInterceptor (doc, example) - Intercept Unary RPCs; can only be used with Promise clients.
  • StreamInterceptor (doc, example) - More versatile; can be used with regular clients.

For more details, see this blog post.

Ecosystem

Proxy Interoperability

Multiple proxies support the gRPC-web protocol.

  1. The current default proxy is Envoy, which supports gRPC-web out of the box.

    $ docker-compose up -d node-server envoy commonjs-client
  2. You can also try the gRPC-web Go proxy.

    $ docker-compose up -d node-server grpcwebproxy binary-client
  3. Apache APISIX has also added grpc-web support, and more details can be found here.

  4. Nginx has a grpc-web module (doc, announcement)), and seems to work with simple configs, according to user feedback.

Server Frameworks with gRPC-Web support

Web Frameworks Compatibility

grpc-web's People

Contributors

06kellyjac avatar at-ishikawa avatar benitogf avatar benjaminp avatar catears avatar danfabi avatar dependabot[bot] avatar dimo414 avatar fengli79 avatar globegitter avatar hanabi1224 avatar hronro avatar jeffwillette avatar johanbrandhorst avatar mitar avatar orphis avatar pro-wh avatar richardpringle avatar rogchap avatar sampajano avatar shaxbee avatar srini100 avatar stanley-cheung avatar travikk avatar vbfox avatar vnorigoog avatar wapa5pow avatar wenbozhu avatar yannic avatar zaucy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grpc-web's Issues

CORS: Dealing with gRPC Metadata in Headers and Access-Control-Expose-Headers

So it seems that browsers only allow access to certain response headers, and the list of headers allowed is controlled through a CORS response headers: Access-Control-Expose-Headers

It is important that grpc-status and grpc-message get exposed as part of this Access-Control-Expose-Headers, in case where there is no payload (an error) and the trailers get merged with headers as part of the spec. I think this should be documented in the spec, otherwise this special case is easy to miss.

However, the true problem is user custom headers. The CORS OPTIONS HTTP request hits the server as a separate request before the real gRPC request is sent and the handler kicks in. This means that the CORS OPTIONS handler doesn't know about the custom headers added by handler user cods, which means it can't predict what custom headers need to be announced in Access-Control-Expose-Headers in the pre-flight request.

A recent change to the Fetch API spec allows for wildcards here:
whatwg/fetch@cdbb13c
But it's not supported by any browser at the moment (compatibility notes).

In the Go implementation of gRPC-Web middleware, I'll add a custom option to the middleware that allows the user to provide a function that returns exposed headers given a fullMethodName, but it is very hard to bake something like this into an nginx proxy. In any case, we should update the protocol spec to make sure that custom headers sent by the gRPC handler is unsupported with CORS as a general statement.

Review the typescript support from the Improbable team

"TypeScript protoc plugin for generating types objects from .proto definitions while using jsonpb marshallers (https://github.com/golang/protobuf/tree/master/jsonpb)"

@mwitkow .. .could you fill us with more detail of how/where the current typescript support is implemented?

Then we can discuss

  1. if we want to promote this to other users who are (only) interested in using typescripts with grpc-web
  2. how to switch to the "official" binary protobuf format (via jspb)

Node-based proxy

Some things I am interested in doing:

  • Running the proxy in a Node.JS process
  • Allowing arbitrary transport to the proxy (websocket, any other two-way link like WebRTC)

Discuss Michal's feedback on the grpc-web protocol spec

a) Message framing of trailer
"8th (MSB) bit of the 1st gRPC frame byte"
I assume you mean the Compressed-Flag of the Delimited-Message in the wire spec?
So for an uncompressed trailer the Compressed-Flag byte would be 10000000b, and for a compressed one it would be 10000001b, right?

b) Trailers encoding
"Response status encoded as part of the response body; Key-value pairs encoded as a HTTP/1 headers block (without the terminating newline)".

Basically what you mean is that the contents of the "trailer frame" (last frame) is just a plaintext HTTP/1.1 header block according to the RFC2616 sec 4 (with CRLF as a separator, I assume?

c) Content-Type and lack of Accept
Assuming an empty request (google.Empty), is the Client expected to always set the Content-Type? Why not Accept and deal with a bi-directional negotiation? Shouldn't it set both Accept and Content-Type?
This is relevant regarding the discussion in grpc-go#803.

d) User agent and Server headers
Can we drop them out of the spec? It may seem like they're needed for the implementation to be compliant, and some may be tempted to make this part of the negotiation. The negotiation should only depend on Content-Type gRPC Web or gRPC is to be used should be over

e) Text Encoding
How does one indicate the marshaller of messages (similar to application/grpc-web+json) for what the text-encoding is "encoding" from raw bytes to base64? Or do we assume that it only works for protos?
Also, you mentioned we could have the text encoding specified as optional. Could we have this marked as such?

golang basis

i am really happy to see this moving forward, and have some comments.

Because its based on NGinx and c i can help test or fix things as i dont use either.
I use golang and want to point out how well golang supports GRPC, and hence i wanted to suggest that writing the GRPC-Web <---> GRPC gateway in golang would be really awesome later.

links in case anyone is curious:
Caddy reverse proxy
https://github.com/mholt/caddy
https://caddyserver.com/docs/proxy

The golang based GRPC-gateway, which does the translation of GRPC to REST.
https://github.com/grpc-ecosystem/grpc-gateway

installation error on macos

I am trying to install grpc-web by running sudo darwin_x86_64.sh but it fails with the following message:

Undefined symbols for architecture x86_64:
"_well_known_types_js", referenced from:
google::protobuf::compiler::js::Generator::GenerateFile(google::protobuf::compiler::js::GeneratorOptions const&, google::protobuf::io::Printer*, google::protobuf::FileDescriptor const*) const in js_generator.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libprotoc.la] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

How to specify a "Authorization" header when creating the service client?

Hello,

as per the echo example:

var service = new proto.grpc.gateway.testing.EchoServiceClient(
    'http://localhost:9091',
    {}, {} // what the credentials & options object look like ?
); 

According to the API, it seems like the client constructor accept a credentials and a options object. Is it possible to use the credentials object to set a Authorization header?

If yes, what the code would look like?

{ Authorization: 'Bearer mytoken' } // This doesn't work

Many thanks!

[Feature request] Server calling client's API.

Many popular Javascript RPC libraries support calling client's API from server, e.g., Socket IO. It would be really great if GRPC-WEB supports that so that it can be a viable alternative to those frameworks.

I know GRPC does not support this, but since it's a pretty common pattern on web so I think it's worth to have a discussion on this.

failed to make examples on OS X Sierra

Hey there,

I can't manage to build examples on Sierra.
As per this README,
https://github.com/grpc/grpc-web/tree/master/net/grpc/gateway/examples/echo

I add EMBED_OPENSSL=false on build It fails thusly:

In file included from src/core/lib/security/credentials/google_default/google_default_credentials.c:46:
In file included from ./src/core/lib/security/credentials/jwt/jwt_credentials.h:38:
./src/core/lib/security/credentials/jwt/json_token.h:38:10: fatal error: 'openssl/rsa.h' file not found
#include <openssl/rsa.h>

but if I omit EMBED_OPOENSSL option, it fails thusly:

grpc-web/net/grpc/gateway/codec/grpc_decoder.cc:86:19: error: no matching function for call to
      'grpc_msg_decompress'int grpc_msg_decompress(grpc_exec_ctx* exec_ctx,

grpc-web/third_party/grpc/src/core/lib/compression/message_compress.h:50:5: note: candidate function not
      viable: requires 4 arguments, but 3 were provided
int grpc_msg_decompress(grpc_exec_ctx* exec_ctx,

These seem unrelated, but am am I missing something?

Cheers.

Node example implementation problem

Hi,

I'm trying to run the example but instead of using the c++ server, I want to use a node server side.
When I run it with the c++ server it's working well but with a node server, it doesn't work at all.
Here is my code :

const grpc = require("grpc");
const message = require("./node/echo_pb");
const service = require("./node/echo_grpc_pb");

function echoFunc(context, callback) {
    console.log("Message received\n");
    let reply = new message.EchoResponse();
    reply.setMessage('Hello' + context.request.getMessage());
    callback(null, reply);
}

function startGrpc() {
    let server = new grpc.Server();
    let credentials = grpc.ServerCredentials.createInsecure();
    server.addService(service.EchoService, {echo: echoFunc});
    server.bind("0.0.0.0:9090", credentials);
    console.log("start server\n");
    server.start();
}

startGrpc();

Can you tell me where I'm wrong ? I got no error on my server and the echoFunc function is not even called when I'm sending a request.

Thank you.

OSX 10.12 build issues

Hey guys,

I tried the new build scripts for 10.12, that is just ./darwin_x86_64.sh and its certainly gotten better but I had a few issues. For one, I needed to prefix ./ before each path.. as so in this diff.

diff --git a/darwin_x86_64.sh b/darwin_x86_64.sh
index 98c2dd7..b7b469b 100755
--- a/darwin_x86_64.sh
+++ b/darwin_x86_64.sh
@@ -1,6 +1,6 @@
 ./init_submodules.sh
 make clean
-cd third_party/protobuf && ./autogen.sh && ./configure && make && cd ../..
-cd third_party/grpc && make && cd ../..
+cd ./third_party/protobuf && ./autogen.sh && ./configure && make && cd ../..
+cd ./third_party/grpc && make && cd ../..
 export KERNEL_BITS=64
 make
diff --git a/init_submodules.sh b/init_submodules.sh
index 4fc9728..cf8651a 100755
--- a/init_submodules.sh
+++ b/init_submodules.sh
@@ -1,5 +1,5 @@
 git submodule update --init
-cd third_party/closure-library && git checkout tags/v20160911 -f && cd ../..
-cd third_party/openssl && git checkout tags/OpenSSL_1_0_2h -f && cd ../..
-cd third_party/protobuf && git checkout tags/v3.0.2 -f && cd ../..
-cd third_party/grpc && git checkout tags/v1.0.1 -f && git submodule update --init && cd ../..
+cd ./third_party/closure-library && git checkout tags/v20160911 -f && cd ../..
+cd ./third_party/openssl && git checkout tags/OpenSSL_1_0_2h -f && cd ../..
+cd ./third_party/protobuf && git checkout tags/v3.0.2 -f && cd ../..
+cd ./third_party/grpc && git checkout tags/v1.0.1 -f && git submodule update --init && cd ../..

however, as this ran, during the make of grpc I ran into the following errors:

https://gist.github.com/pkieltyka/c0886b58de3c58af771693b45c61e163

one thing that is strange, is that its using my system protoc instead of the third_party/protobuf that was just built. I just wanted to show you the current results in the current state.

Safari, refused to set unsafe header

Echo example doesn't work in safari. In chrome, firefox everything is fine.

Console log:

[Error] Refused to set unsafe header "Content-Transfer-Encoding"
	(анонимная функция) (compiled.js:9396)
	forEach (compiled.js:7638)
	send (compiled.js:9395)
	rpcCall (compiled.js:10597)
	Echo (compiled.js:10825)
	echo (33.33.33.31:34)
	send (33.33.33.31:68)
	dispatch (jquery-3.1.1.min.js:3:10321)

Making echo example fails when protoc >= 3.3.0

$ EMBED_OPENSSL=false make

[MAKE] Generating cache.mk
[C] Compiling src/core/ext/transport/cronet/transport/cronet_api_dummy.c
[C] Compiling src/core/ext/transport/cronet/transport/cronet_transport.c
[AR] Creating /usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/libs/opt/libgrpc_cronet.a
[AR] Creating /usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/libs/opt/libgrpc_unsecure.a
[CXX] Compiling src/cpp/server/health/default_health_check_service.cc
[C] Compiling src/cpp/server/health/health.pb.c
[AR] Creating /usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/libs/opt/libgrpc++.a
[AR] Creating /usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/libs/opt/libgrpc++_cronet.a
[CXX] Compiling src/cpp/ext/proto_server_reflection.cc
In file included from /usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/gens/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h:39:0,
from ./src/cpp/ext/proto_server_reflection.h:41,
from src/cpp/ext/proto_server_reflection.cc:39:
/usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/gens/src/proto/grpc/reflection/v1alpha/reflection.pb.h:12:2: error: #error This file was generated by a newer version of protoc which is
#error This file was generated by a newer version of protoc which is
^
/usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/gens/src/proto/grpc/reflection/v1alpha/reflection.pb.h:13:2: error: #error incompatible with your Protocol Buffer headers. Please update
#error incompatible with your Protocol Buffer headers. Please update
^
/usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/gens/src/proto/grpc/reflection/v1alpha/reflection.pb.h:14:2: error: #error your headers.
#error your headers.
^
In file included from /usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/gens/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.h:39:0,
from ./src/cpp/ext/proto_server_reflection.h:41,
from src/cpp/ext/proto_server_reflection.cc:39:
/usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/gens/src/proto/grpc/reflection/v1alpha/reflection.pb.h:25:60: fatal error: google/protobuf/generated_message_table_driven.h: No such file or directory
#include <google/protobuf/generated_message_table_driven.h>
^
compilation terminated.
make: *** [/usr/local/google/home/michaelaaron/OpenSource/grpc-web/third_party/grpc/objs/opt/src/cpp/ext/proto_server_reflection.o] Error 1

I didn't see this error when I build with protoc v3.1.0

Cannot build successfully on Ubuntu 12.04/14.04 based docker container

I'am running on mac with version 10.12.4 (16E195)
and docker version 17.03.1-ce-mac12

I have trouble in building grpc-web with
ubuntu_12_04.sh

Step 9/10 : RUN cd /github/grpc-web/third_party/grpc &&   make -j
...
...
src/cpp/server/health/default_health_check_service.cc: In constructor 'grpc::DefaultHealthCheckService::DefaultHealthCheckService()':
src/cpp/server/health/default_health_check_service.cc:132:17: error: 'class std::map<std::basic_string<char>, bool>' has no member named 'emplace'
make: *** [/github/grpc-web/third_party/grpc/objs/opt/src/cpp/server/health/default_health_check_service.o] Error 1
make: *** Waiting for unfinished jobs....
libtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./config.guess'
libtoolize: copying file `./config.sub'
libtoolize: copying file `./install-sh'
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
configure.ac:65: installing `./ar-lib'
configure.ac:48: installing `./missing'
benchmarks/Makefile.am: installing `./depcomp'
The command '/bin/sh -c cd /github/grpc-web/third_party/grpc &&   make -j' returned a non-zero code: 2

Also have trouble in building grpc-web with
ubuntu_14_04.sh

Step 4/5 : RUN cd /github/grpc-web/third_party/grpc &&   make -j
...
...
[MAKE]    Building protobuf
...
...
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
make[3]: *** [google/protobuf/text_format.lo] Error 1
make[3]: *** Waiting for unfinished jobs....
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/type.pb.lo] Error 1
make[3]: *** [google/protobuf/wire_format.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/unknown_field_set.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
make[3]: *** [google/protobuf/timestamp.pb.lo] Error 1
make[3]: *** [google/protobuf/io/printer.lo] Error 1
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
make[3]: *** [google/protobuf/util/message_differencer.lo] Error 1
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/objectivec/objectivec_generator.lo] Error 1
make[3]: *** [google/protobuf/compiler/csharp/csharp_generator.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
make[3]: *** [google/protobuf/compiler/javanano/javanano_message.lo] Error 1
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/csharp/csharp_enum_field.lo] Error 1
make[3]: *** [google/protobuf/compiler/java/java_enum_lite.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/objectivec/objectivec_extension.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
make[3]: *** [google/protobuf/compiler/csharp/csharp_repeated_message_field.lo] Error 1
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/java/java_enum_field_lite.lo] Error 1
make[3]: *** [google/protobuf/compiler/cpp/cpp_generator.lo] Error 1
make[3]: *** [google/protobuf/compiler/objectivec/objectivec_primitive_field.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/java/java_message_field_lite.lo] Error 1
make[3]: *** [google/protobuf/generated_message_reflection.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/java/java_enum.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
make[3]: *** [google/protobuf/extension_set_heavy.lo] Error 1
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
make[3]: *** [google/protobuf/util/internal/type_info.lo] Error 1
make[3]: *** [google/protobuf/empty.pb.lo] Error 1
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/util/internal/protostream_objectsource.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
make[3]: *** [google/protobuf/compiler/ruby/ruby_generator.lo] Error 1
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/util/internal/utility.lo] Error 1
make[3]: *** [google/protobuf/compiler/java/java_string_field_lite.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/dynamic_message.lo] Error 1
make[3]: *** [google/protobuf/util/internal/type_info_test_helper.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/util/internal/datapiece.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/java/java_message_field.lo] Error 1
make[3]: *** [google/protobuf/compiler/php/php_generator.lo] Error 1
make[3]: *** [google/protobuf/message.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/cpp/cpp_helpers.lo] Error 1
make[3]: *** [google/protobuf/compiler/objectivec/objectivec_message_field.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/cpp/cpp_message.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/java/java_primitive_field_lite.lo] Error 1
make[3]: *** [google/protobuf/compiler/cpp/cpp_file.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/reflection_ops.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/csharp/csharp_source_generator_base.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/javanano/javanano_generator.lo] Error 1
make[3]: *** [google/protobuf/compiler/objectivec/objectivec_helpers.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/csharp/csharp_field_base.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
make[3]: *** [google/protobuf/compiler/java/java_helpers.lo] Error 1
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/descriptor_database.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/duration.pb.lo] Error 1
make[3]: *** [google/protobuf/api.pb.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/command_line_interface.lo] Error 1
make[3]: *** [google/protobuf/compiler/javanano/javanano_helpers.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/java/java_message_builder_lite.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/objectivec/objectivec_message.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/descriptor.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/java/java_message_lite.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/descriptor.pb.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/struct.pb.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/util/field_mask_util.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/java/java_map_field.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/java/java_map_field_lite.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/javanano/javanano_map_field.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/cpp/cpp_extension.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/cpp/cpp_service.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/cpp/cpp_map_field.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/cpp/cpp_message_field.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/objectivec/objectivec_field.lo] Error 1
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.8/README.Bugs> for instructions.
make[3]: *** [google/protobuf/compiler/javanano/javanano_primitive_field.lo] Error 1
make[3]: Leaving directory `/github/grpc-web/third_party/grpc/third_party/protobuf/src'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/github/grpc-web/third_party/grpc/third_party/protobuf'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/github/grpc-web/third_party/grpc/third_party/protobuf'
make: *** [/github/grpc-web/third_party/grpc/libs/opt/protobuf/libprotobuf.a] Error 2
The command '/bin/sh -c cd /github/grpc-web/third_party/grpc &&   make -j' returned a non-zero code: 2

Any ideas or advises?

Troubles getting started on OS X 10.11.6 (El Capitan)

Hi guys,

I spent some time trying to run the examples on my Mac, but ended up quitting after getting too many errors.

I'm sharing a history of what I tried to do, and what I got.

$ git clone https://github.com/grpc/grpc-web

$ cd grpc-web

$ ./build.sh 
ERRO[0001] Can't add file /Users/adrienjoly/dev/github/grpc-web/.git/index to tar: io: read/write on closed pipe 
ERRO[0001] Can't close tar writer: io: read/write on closed pipe 
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

$ ./ubuntu_14_04.sh 
Cannot connect to the Docker daemon. Is the docker daemon running on this host?

$ ./init_submodules.sh 

$ make
protoc: command not found

$ brew install --devel protobuf

$ make
checking for --with-ld-opt="-L /usr/local/lib -lgrpc++ -lgrpc -lprotobuf -lpthread -lstdc++ -lm" ... not found
auto/configure: error: the invalid value in --with-ld-opt="-L /usr/local/lib -lgrpc++ -lgrpc -lprotobuf -lpthread -lstdc++ -lm"

$ cd third_party/grpc && git submodule update --init && EMBED_OPENSSL=false make
json_token.h:38:10: fatal error: 'openssl/rsa.h' file not found

$ brew update

$ brew upgrade openssl
==> Pouring openssl-1.0.2j.el_capitan.bottle.tar.gz

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

$ cd third_party/grpc/

$ export EXTRA_CFLAGS=-I/usr/local/opt/openssl/include && export EXTRA_CXXFLAGS=-I/usr/local/opt/openssl/include & export EXTRA_LDFLAGS=-L/usr/local/opt/openssl/lib & make
Package zlib was not found in the pkg-config search path

$ export PKG_CONFIG_PATH=/anaconda/lib/pkgconfig && export EXTRA_CFLAGS=-I/usr/local/opt/openssl/include && export EXTRA_CXXFLAGS=-I/usr/local/opt/openssl/include && export EXTRA_LDFLAGS=-L/usr/local/opt/openssl/lib && make
[MAKE]    Generating cache.mk
[CXX]     Compiling src/cpp/ext/reflection.pb.cc
In file included from src/cpp/ext/reflection.pb.cc:47:
/usr/local/Cellar/protobuf/3.0.0-beta-4/include/google/protobuf/wire_format_lite_inl.h:352:17: error: comparison of integers of different signs:
      'const uint32' (aka 'const unsigned int') and 'int' [-Werror,-Wsign-compare]
  if (new_bytes != length) return false;
      ~~~~~~~~~ ^  ~~~~~~
/usr/local/Cellar/protobuf/3.0.0-beta-4/include/google/protobuf/wire_format_lite_inl.h:415:1: note: in instantiation of function template
      specialization 'google::protobuf::internal::WireFormatLite::ReadPackedFixedSizePrimitive<unsigned int,
      google::protobuf::internal::WireFormatLite::FieldType::TYPE_FIXED32>' requested here
READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(uint32, TYPE_FIXED32)
^

That's just a sample of all the error I got.

At that point, I decided to call it a day.

Hope this helps you in any way.

Cheers!

Problem compiling on ARM with gcc 6.1.1

Hello!

We've got some issues while compiling on ARM (Cortex A8).

  • OS is Debian Stretch
  • gcc version is 6.1.1

The problem is related to some debugging macro with printf and wrong type. Related files are nginx_notify_queue.cc and nginx_http_frontend.cc

This is the error report:

cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I /usr/local/include -I /opt/grpc-web -I /opt/grpc-web/third_party/protobuf/src -I /opt/grpc-web/third_party/grpc/include -std=c++11  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /opt/grpc-web/third_party/openssl/.openssl/include -I ./objs -I src/http -I src/http/modules -I src/http/v2 \
        -o ./objs/addon/runtime/nginx_notify_queue.o \
        /opt/grpc-web/net/grpc/gateway/runtime/nginx_notify_queue.cc
In file included from /opt/grpc-web/net/grpc/gateway/runtime/nginx_notify_queue.cc:8:0:
/opt/grpc-web/net/grpc/gateway/runtime/nginx_notify_queue.cc: In member function ‘void grpc::gateway::NginxNotifyQueue::Add(std::unique_ptr<grpc::gateway::Tag>)’:
/opt/grpc-web/net/grpc/gateway/log.h:33:48: error: format ‘%li’ expects argument of type ‘long int’, but argument 5 has type ‘ngx_int_t {aka int}’ [-Werror=format=]
 #define ERROR_1(f, v1) gpr_log(GPR_ERROR, f, v1);
                                                ^
/opt/grpc-web/net/grpc/gateway/log.h:37:50: note: in definition of macro ‘ERROR_X’
 #define ERROR_X(x, f, v1, v2, v3, v4, func, ...) func
                                                  ^~~~
/opt/grpc-web/net/grpc/gateway/log.h:42:29: note: in expansion of macro ‘ERROR_1’
                             ERROR_1(f, __VA_ARGS__), \
                             ^~~~~~~
/opt/grpc-web/net/grpc/gateway/runtime/nginx_notify_queue.cc:42:5: note: in expansion of macro ‘ERROR’
     ERROR("ngx_notify failed, rc = %li", rc);
     ^~~~~

We fixed it here: https://goo.gl/Zn4OZt
Maybe this is due to the compiler version; I hope it helps.

Thanks!

Update the spec to support CORS preflight bypassing

CORS preflight costs at least one RTT for initial requests.

To bypass preflight, we need support method and header overwrite with URL params.

File new issues for implementing the feature in the JS client library, Nginx and Envoy.

react native support?

Will grpc-web officially support React Native?

Here's some more information about what that javascript execution environment looks like on various platforms.

Thanks!

Spec bug: trailer only responses

The current spec follows the grpc spec to send trailers with/as response headers.

This is problematic for browser clients (or other clients too?) as headers are supposed to be dispatched atomically. I.e. the stream open will be delayed until the first message or an error status.

SSL/TLS

Hello,

I can't find a way to use SSL with GRPC web. When do you plan to implement this feature?

Thank you,
Bastien.

How to reduce the size of compiled.js

Hello,

As I understand, there are 3 main parts that make the bundle:

  1. grpc-web library
  2. protobuf library
  3. messages and service definitions from the .proto file.

for a simple grpc service (10 rpc methods, 20 messages definitions), the compiled.js produced by running closurebuilder.py is around 400KB.

Is there any way to make this bundle smaller ? Any insights on which JS files weights the most into these 400KB ?

My second question is, when using closurebuilder.py, I need to specify a namespace="proto.packageName.serviceNameClient" flag. How to handle the case where I have 2 or 3 services defined in my protos files? Should I repeat the command, with a different namespace for each compiler run? I don't want to produce 3 bundles, with the same grpc-web library and protobuf JS library repeated in each of these bundles...

Finally, in the grpc-web JS libary, I can see many required files like this:

goog.require('grpc.web.AbstractClientBase');
goog.require('grpc.web.ClientReadableStream');
goog.require('grpc.web.Status');
goog.require('grpc.web.StatusCode');

May I ask where these dependencies are located ? I'm considering the option to build the compiled.js with something like webpack instead of closurebuilder.py.

Many thanks

All proxy responses are getting truncated past 65335 bytes

Heya,

We are starting to get some large payloads back through the proxy, unfortunetly it appears the proxy always truncates at 65335 bytes, leading to the proxy forwarding invalid payloads. The curl request below demonstrates the issue. The {{AUTH_TOKENS}} you can try are located here: https://paste.googleplex.com/4771580840247296
You'll need to be on GoogleA or the VPN to talk with the service.

curl 'https://firebird.phoenix.nestlabs.com:9041/nestlabs.gateway.v2.GatewayService/Observe' -H 'Origin: null' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.8' -H 'Authorization: Basic {{AUTH_TOKEN}}' -H 'Content-Type: application/json' -H 'Accept: */*' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36' -H 'Connection: keep-alive' -H 'Request-Id: 1b682f73-5c9a-4771-8f15-1f72ef8f7aca' --data-binary '[{"1":"CgIBAg=="}]' --compressed

Troubles getting started on OS X 10.12

Hey guys, I will continue my work on Linux but I wanted to report some issues when trying to build grpc/grpc-web on 10.12. Specifically third_party/grpc (which is v1.0.0 from August) fails to build due to these errors:

[peter@pak ~/Dev/other/grpc-web/third_party/grpc]$ make
... etc...
[CXX]     Compiling src/cpp/util/string_ref.cc
[CXX]     Compiling src/cpp/util/time.cc
[HOSTCXX] Compiling src/compiler/cpp_generator.cc
[HOSTCXX] Compiling src/compiler/csharp_generator.cc
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:47:9: error: 'OSAtomicCompareAndSwap32' is deprecated: first
      deprecated in macOS 10.12 - Use std::atomic_compare_exchange_strong_explicit(std::memory_order_relaxed) from <atomic> instead [-Werror,-Wdeprecated-declarations]
    if (OSAtomicCompareAndSwap32(old_value, new_value,
        ^
/usr/include/libkern/OSAtomicDeprecated.h:502:9: note: 'OSAtomicCompareAndSwap32' has been explicitly marked deprecated here
bool    OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:61:13: error: 'OSAtomicCompareAndSwap32' is deprecated: first
      deprecated in macOS 10.12 - Use std::atomic_compare_exchange_strong_explicit(std::memory_order_relaxed) from <atomic> instead [-Werror,-Wdeprecated-declarations]
  } while (!OSAtomicCompareAndSwap32(old_value, new_value,
            ^
/usr/include/libkern/OSAtomicDeprecated.h:502:9: note: 'OSAtomicCompareAndSwap32' has been explicitly marked deprecated here
bool    OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:68:10: error: 'OSAtomicAdd32' is deprecated: first deprecated in
      macOS 10.12 - Use std::atomic_fetch_add_explicit(std::memory_order_relaxed) from <atomic> instead [-Werror,-Wdeprecated-declarations]
  return OSAtomicAdd32(increment, const_cast<Atomic32*>(ptr));
         ^
/usr/include/libkern/OSAtomicDeprecated.h:146:9: note: 'OSAtomicAdd32' has been explicitly marked deprecated here
int32_t OSAtomicAdd32( int32_t __theAmount, volatile int32_t *__theValue );
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:73:10: error: 'OSAtomicAdd32Barrier' is deprecated: first deprecated
      in macOS 10.12 - Use std::atomic_fetch_add() from <atomic> instead [-Werror,-Wdeprecated-declarations]
  return OSAtomicAdd32Barrier(increment, const_cast<Atomic32*>(ptr));
         ^
/usr/include/libkern/OSAtomicDeprecated.h:161:9: note: 'OSAtomicAdd32Barrier' has been explicitly marked deprecated here
int32_t OSAtomicAdd32Barrier( int32_t __theAmount, volatile int32_t *__theValue );
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:77:3: error: 'OSMemoryBarrier' is deprecated: first deprecated in
      macOS 10.12 - Use std::atomic_thread_fence() from <atomic> instead [-Werror,-Wdeprecated-declarations]
  OSMemoryBarrier();
  ^
/usr/include/libkern/OSAtomicDeprecated.h:749:9: note: 'OSMemoryBarrier' has been explicitly marked deprecated here
void    OSMemoryBarrier( void );
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:85:9: error: 'OSAtomicCompareAndSwap32Barrier' is deprecated: first
      deprecated in macOS 10.12 - Use std::atomic_compare_exchange_strong() from <atomic> instead [-Werror,-Wdeprecated-declarations]
    if (OSAtomicCompareAndSwap32Barrier(old_value, new_value,
        ^
/usr/include/libkern/OSAtomicDeprecated.h:518:9: note: 'OSAtomicCompareAndSwap32Barrier' has been explicitly marked deprecated here
bool    OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue );
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:138:9: error: 'OSAtomicCompareAndSwap64' is deprecated: first
      deprecated in macOS 10.12 - Use std::atomic_compare_exchange_strong_explicit(std::memory_order_relaxed) from <atomic> instead [-Werror,-Wdeprecated-declarations]
    if (OSAtomicCompareAndSwap64(old_value, new_value,
        ^
/usr/include/libkern/OSAtomicDeprecated.h:628:9: note: 'OSAtomicCompareAndSwap64' has been explicitly marked deprecated here
bool    OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue,
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:152:13: error: 'OSAtomicCompareAndSwap64' is deprecated: first
      deprecated in macOS 10.12 - Use std::atomic_compare_exchange_strong_explicit(std::memory_order_relaxed) from <atomic> instead [-Werror,-Wdeprecated-declarations]
  } while (!OSAtomicCompareAndSwap64(old_value, new_value,
            ^
/usr/include/libkern/OSAtomicDeprecated.h:628:9: note: 'OSAtomicCompareAndSwap64' has been explicitly marked deprecated here
bool    OSAtomicCompareAndSwap64( int64_t __oldValue, int64_t __newValue,
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:159:10: error: 'OSAtomicAdd64' is deprecated: first deprecated in
      macOS 10.12 - Use std::atomic_fetch_add_explicit(std::memory_order_relaxed) from <atomic> instead [-Werror,-Wdeprecated-declarations]
  return OSAtomicAdd64(increment, reinterpret_cast<volatile int64_t*>(ptr));
         ^
/usr/include/libkern/OSAtomicDeprecated.h:231:9: note: 'OSAtomicAdd64' has been explicitly marked deprecated here
int64_t OSAtomicAdd64( int64_t __theAmount,
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:164:10: error: 'OSAtomicAdd64Barrier' is deprecated: first deprecated
      in macOS 10.12 - Use std::atomic_fetch_add() from <atomic> instead [-Werror,-Wdeprecated-declarations]
  return OSAtomicAdd64Barrier(increment,
         ^
/usr/include/libkern/OSAtomicDeprecated.h:247:9: note: 'OSAtomicAdd64Barrier' has been explicitly marked deprecated here
int64_t OSAtomicAdd64Barrier( int64_t __theAmount,
        ^
In file included from src/compiler/csharp_generator.cc:39:
In file included from ./src/compiler/csharp_generator.h:37:
In file included from ./src/compiler/config.h:37:
In file included from include/grpc++/impl/codegen/config_protobuf.h:43:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/message.h:118:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/arena.h:54:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomic_sequence_num.h:33:
In file included from /usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops.h:199:
/usr/local/Cellar/google-protobuf/3.0.2/include/google/protobuf/stubs/atomicops_internals_macosx.h:173:9: error: 'OSAtomicCompareAndSwap64Barrier' is deprecated: first
      deprecated in macOS 10.12 - Use std::atomic_compare_exchange_strong() from <atomic> instead [-Werror,-Wdeprecated-declarations]
    if (OSAtomicCompareAndSwap64Barrier(
        ^
/usr/include/libkern/OSAtomicDeprecated.h:645:9: note: 'OSAtomicCompareAndSwap64Barrier' has been explicitly marked deprecated here
bool    OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue,
        ^
11 errors generated.
make: *** [/Users/peter/Dev/other/grpc-web/third_party/grpc/objs/opt/src/compiler/csharp_generator.o] Error 1

ARM worker process exited – std::logic_error

We have the following scenario:

  • a grpc server running on an ARM device
  • nginx (on the same device) is serving the static js files and the web page
  • nginx is also acting as proxy for the grpc server through grpc-web

We are getting problems whenever trying to access the grpc-server from grpc-web in the nginx error.log.

GET and POST calls gets net::ERR_EMPTY_RESPONSE and worker exits with the following error:

2017/01/20 17:40:39 [alert] 2444#0: worker process 2604 exited on signal 6
terminate called after throwing an instance of 'std::logic_error'
  what():  basic_string::_S_construct null not valid

This is what strace returns when monitoring the worker PID.

[pid  8271] <... epoll_pwait resumed> {}, 1000, 1000, [], 8) = 0
[pid  8271] clock_gettime(CLOCK_MONOTONIC, {18118, 881253740}) = 0
[pid  8271] epoll_pwait(3,  <unfinished ...>
[pid  8270] <... epoll_wait resumed> {{EPOLLIN, {u32=3062833288, u64=1862013119570056}}}, 512, 74968) = 1
[pid  8270] gettimeofday({1484934844, 145833}, NULL) = 0
[pid  8270] accept4(7, {sa_family=AF_INET, sin_port=htons(52208), sin_addr=inet_addr("192.168.2.10")}, [16], SOCK_NONBLOCK) = 16
[pid  8270] epoll_ctl(10, EPOLL_CTL_ADD, 16, {EPOLLIN|EPOLLRDHUP|EPOLLET, {u32=3062833928, u64=1544305798750984}}) = 0
[pid  8270] epoll_wait(10, {{EPOLLIN, {u32=3062833288, u64=1862013119570056}}, {EPOLLIN, {u32=3062833928, u64=1544305798750984}}}, 512, 60000) = 2
[pid  8270] gettimeofday({1484934844, 152854}, NULL) = 0
[pid  8270] accept4(7, {sa_family=AF_INET, sin_port=htons(52210), sin_addr=inet_addr("192.168.2.10")}, [16], SOCK_NONBLOCK) = 17
[pid  8270] epoll_ctl(10, EPOLL_CTL_ADD, 17, {EPOLLIN|EPOLLRDHUP|EPOLLET, {u32=3062834056, u64=1544305798751112}}) = 0
[pid  8270] recv(16, "POST /orchid.CncPistonDisp/GetSe"..., 1024, 0) = 504
[pid  8270] write(2, "terminate called after throwing "..., 48) = 48
[pid  8270] write(2, "std::logic_error", 16) = 16
[pid  8270] write(2, "'\n", 2)          = 2
[pid  8270] write(2, "  what():  ", 11) = 11
[pid  8270] write(2, "basic_string::_S_construct null "..., 41) = 41
[pid  8270] write(2, "\n", 1)           = 1
[pid  8270] rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
[pid  8270] tgkill(8270, 8270, SIGABRT) = 0
[pid  8270] --- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=8270, si_uid=33} ---
[pid  8271] +++ killed by SIGABRT +++

We are now delving into this issue that seems related to the architecture, but any advice on this would be great.

How to know if the client is using http or http2?

I see in the nginx example that it can listen for both http and http2 calls, given two different ports:

server {
    listen 9091;
    listen 9092 http2;
    server_name localhost;
    location / {
      grpc_pass localhost:9090;
      if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Transfer-Encoding,Custom-Header-1,X-Accept-Content-Transfer-Encoding,X-Accept-Response-Streaming';
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
      }
      if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Transfer-Encoding,Custom-Header-1,X-Accept-Content-Transfer-Encoding,X-Accept-Response-Streaming';
        add_header 'Access-Control-Expose-Headers' 'Content-Transfer-Encoding';
      }
    }
  }

Does it mean that the JS grpc-web client knows how to upgrade to http2 if the given port is http2?
If the given port when creating the client is the http one, how the grpc-web client can support the streaming features (server push for example)?

I'm not clear on this point,

thank you for your help!

Not getting a proper base64 encoded response, but "content-type:application/x-protobuf" instead

I'm running 2 nginx gateway:

  • one on my local ubuntu 16.04 machine,
  • and one on a remote centos7 machine.

Here is the call response on the remote nginx gateway (Not OK):
selection_003
selection_002

Here is the call on the local nginx gateway (OK):
screenshot from 2017-03-27 18-06-54
selection_001

I don't understand how, with the same nginx config, one call response encoding is "base64", and the other one is "application/x-protobuf" ?

here is the remote centos7 nginx config:

server {
    listen 60252;
    listen 60152 http2;
    server_name xx.xxxxx.net;
   location / {
      grpc_pass localhost:60052;
      if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Transfer-Encoding,Custom-Header-1,Authorization';
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
      }
      if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Transfer-Encoding,Custom-Header-1,Authorization';
        add_header 'Access-Control-Expose-Headers' 'Content-Transfer-Encoding';
      }
    }
  }

And here is my local, ubuntu 16.04, nginx config:

 server {
    listen 60252;
    listen 60152 http2;
    server_name localhost;
    location / {
      grpc_pass localhost:60052;
      if ($request_method = 'OPTIONS') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Transfer-Encoding,Custom-Header-1,Authorization';
        add_header 'Access-Control-Max-Age' 1728000;
        add_header 'Content-Type' 'text/plain charset=UTF-8';
        add_header 'Content-Length' 0;
        return 204;
      }
      if ($request_method = 'POST') {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Transfer-Encoding,Custom-Header-1,Authorization';
        add_header 'Access-Control-Expose-Headers' 'Content-Transfer-Encoding';
      }
    }
  }

Thank you for your input, or any idea about the possible cause of this encoding problem.

cheers

Why need to compile grpc to use grpc-web ?

Hello,

I don't really understand why I'm supposed to build grpc, as recommended in the readme.md?

Isn't grpc-web supposed to be a pure JS implementation? I yes, what are the steps to try it?

Many thanks!

note: I'm using Ubuntu 16.04

"Unsupported major.minor version 52.0" when building example

TL;DR

I had some issues building the "echo" example. This ticket documents some of my feedback so far.

  1. A recent Closure compiler release seems to cause failures on Ubuntu 14.04.
  2. The Pre-Requisites section says the build scripts will be sufficient, but they aren't.
  3. The instructions for using the Ubuntu 14.04 Docker container are never stated.
  4. The instructions for running the example have a minor issue with the stated path.
  5. When running from Docker, need to find the ip address manually.

Some of my confusion may be due to the fact that the Docker container is built in the initial steps, but after that the assumption seems to be that you're running on Ubuntu 14.04 natively. Should I be running inside Docker? If so, a Dockerfile for the example would be a great way to streamline the setup process.

The Narrative

In the "Pre-Requisites" section, the examples document states:

Use the build scripts or follow the step-by-step instruction.

I installed Docker and ran the build script, ./ubuntu_14_04.sh. With the container created, I used docker run -it ubuntu_14_04 to enter the container and changed to /github/grpc-web to prepare to build the example from the container. That last bit wasn't quite documented, but I figured it out. So far so good.

Following through the example README, I would expect that at this point the whole pre-requisites section would be done, since I used the build script. However, I don't see the closure compiler in the /github/grpc-web directory. That's not so bad though, I can go through the steps manually. Most of it should be redundant, but no biggie. I went through all the steps manually, skipping, of course, the MacOS instructions and skipping cloning the repo (since it has already been cloned).

sudo apt-get install autoconf automake build-essential curl git \
  default-jdk default-jre libtool libpcre3 libpcre3-dev libssl-dev \
  make wget zip
cd third_party/grpc
git submodule update --init
cd third_party/protobuf
./autogen.sh && ./configure && make
sudo make install                       # install protobuf
cd ../..
EMBED_OPENSSL=false make
sudo EMBED_OPENSSL=false make install   # install gRPC
cd /github/grpc-web # go to repo root
wget https://dl.google.com/closure-compiler/compiler-latest.zip -O compiler-latest.zip # I used https instead of http

I didn't notice any errors in the above steps, so at this point all of the pre-requisite steps should definitely be done. Time to build the example:

make example

After chugging for a while, the output yields the following error:

../../../../../third_party/closure-library/closure/bin/build/closurebuilder.py: Compiling with the following command: java -client -jar ../../../../../closure-compiler.jar --flagfile /tmp/tmp1wXE8h
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/javascript/jscomp/CommandLineRunner : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:803)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:442)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:64)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:354)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Traceback (most recent call last):
  File "../../../../../third_party/closure-library/closure/bin/build/closurebuilder.py", line 293, in <module>
    main()
  File "../../../../../third_party/closure-library/closure/bin/build/closurebuilder.py", line 282, in main
    compiler_flags=options.compiler_flags)
  File "/github/grpc-web/third_party/closure-library/closure/bin/build/jscompiler.py", line 160, in Compile
    raise JsCompilerError('JavaScript compilation failed.')
jscompiler.JsCompilerError: JavaScript compilation failed.
make[1]: *** [compiled-js] Error 1
make[1]: Leaving directory `/github/grpc-web/net/grpc/gateway/examples/echo'
make: *** [example] Error 2

I inspected the closure compiler, and it seems to be using Java 8, as version "52.0" would imply. The default java version for Ubuntu 14.04 is Java 7 and upgrading it to Java 8 requires a PPA. The most logical cause of this issue I could come up with was the fact that we downloaded the latest closure compiler, which may have introduced this problem since the original example instructions were written.

Reading through the Closure compiler release notes I noted that the Sept 10th 2017 release version says "Building the compiler and its tests now requires Java 8." OK, so we're not building the compiler itself, but it seem plausible that that version may have introduced a backwards compatibility issue for us.

So, I tried downloading the compiler version for Aug 6th 2017, which came just before that Sept 10th release:

rm closer-compiler.jar
wget https://dl.google.com/closure-compiler/compiler-20170806.zip
unzip -p -qq -o compiler-20170806.zip *.jar > closure-compiler.jar
make example

Success! No version error. Now installing and running the script:

sudo make install-example
cd net/grpc/gateway/examples/echo && ./echo_server &
cd gConnector && ./nginx.sh & # This fails! Need to go back to /github/grpc-web first

Since I'm running all this inside the docker container, I grabbed the IP address of the container ("inet addr" from ifconfig eth0) and opened the web page from the Docker host operating system, in my case it looked like this: http://172.17.0.2:8080/net/grpc/gateway/examples/echo/echotest.html.

Success! I can send messages and receive the echo from the server.

Next Steps

The Closure compiler is the main issue here. Do we hard-code the August 6th release for now? Do we upgrade Java to Java 8 with a PPA? Upgrade Ubuntu 14.04 to 14.10 or 16.04?

Personally I think it'd be helpful to deal with this at the Dockerfile level. If we created a Dockerfile for the "echo" example, it'd really help new users of the project to get started quickly.

CORS indicator header auto indicator

@wenbozhu we hit a little snag in our implementation.

If a user wants to expose other HTTP methods other than gRPC, the CORS handling must not accept requests other than the ones registered on the gRPC server. However, there's no way of telling what Content-Type the CORS pre-flight check is.

We've worked around this by:
a) allowing the user to automatically register all methods of the gRPC server in our gRPC-Go wrapper
b) allowing the user to whitelist all CORS automatically that carry x-gprc-web header in the pre-flight requests Access-Control-Request-Headers

we'd like to extend the spec to make sure that all gRPC-Web requests have the x-grpc-web: 1 header added to them to so we can enable this auto-cors thing.

@MarcusImprobable for context.

Why grpc-gateway mode is base64?

Hello,

I'm wondering why the nginx-gateway is responding with base64 strings, instead of directly sending binary protobuf messages over the wire?

And is there a way to change the mode=base64 to mode=binary when compiling the gateway (it that makes sense of course)

Thank you :)

Missing function due to grpc pointing to an old version

Hello!

We are getting an issue while compiling grpc-web gateway module:

/opt/grpc-web/net/grpc/gateway/runtime/grpc_event_queue.cc:16:59: error: ‘grpc_completion_queue_create_for_next’ was not declared in this scope
     : queue_(grpc_completion_queue_create_for_next(nullptr)), thread_id_(0) {}

It fails due to a not declared variable grpc_completion_queue_create_for_next.

That function is not defined in the grpc version that grpc-web points to: grpc @ a9dbc97 and it has been implemented in newer versions.

Does the requirement need to be updated in the third_party module or am I missing something?

Map deserialize binary AssertionError

I have added map field to echo.proto.
When map key or value is 0 or False respectively, request callback is not called and no any exceptions appear in the console.

After adding try catch in grpc.web.ClientReadableStream.prototype.on I get goog.asserts.AssertionError in the jspb.Map.deserializeBinary.

Proto:

syntax = "proto3";

message EchoResponse {
  string message = 1;
  int32 message_count = 2;
  map<int32, bool> map = 3;
}
service EchoService {
  rpc Echo(EchoRequest) returns (EchoResponse);
}

Server:

class EchoServiceServicer(echo_pb2.EchoServiceServicer):
    def Echo(self, request, context):
        data = {
            'message': 'Hello %s' % request.message,
            'message_count': 1,
            'map': {0: True} 
        }
        request = echo_pb2.EchoResponse(**data)
        return request
...

Thanks.

Trouble running examples on OS X 10.11.6 (El Capitan)

After being able to build the project on El Capitan (#7), I'm having problems to run the example:

  • When I run make example, I get a message saying that I should use the darwin script. So I interrupted the script, and re-ran the darwin script.
  • To run make from grpc-web/net/grpc/gateway/examples/echo, I had to re-install protoc (using brew install protobuf), but then I got the following error:
echo$ make
protoc -I . --cpp_out=. echo.proto
g++ -std=c++11 -I/usr/local/include -I../../../../.. -pthread  -c -o echo.pb.o echo.pb.cc
protoc -I . --grpc_out=. \
  --plugin=protoc-gen-grpc=`which grpc_cpp_plugin` echo.proto
g++ -std=c++11 -I/usr/local/include -I../../../../.. -pthread  -c -o echo.grpc.pb.o echo.grpc.pb.cc
g++ -std=c++11 -I/usr/local/include -I../../../../.. -pthread  -c -o echo_server.o echo_server.cc
g++ echo.pb.o echo.grpc.pb.o echo_server.o -L/usr/local/lib -lgrpc++ -lgrpc -Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed -lprotobuf -lpthread -ldl -o echo_server
ld: unknown option: --no-as-needed
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [echo_server] Error 1

Am I doing anything wrong?

I happy to try something else, if you have any suggestions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.