Replies: 8 comments 28 replies
-
@jmzwcn Thanks for sharing! Glad to hear it works on Nginx! :) Sharing a few related links i found here: Announcements: API: Code: |
Beta Was this translation helpful? Give feedback.
-
Awesome! Is there any info for grpc-web support ? |
Beta Was this translation helpful? Give feedback.
-
I can't get it running 🤔 , our grpc-java service is throwing the following exception we have the following setup: request from grpc-web looks like this
nginx(running in docker) has following config
grpc-java service(running on port 9090) is throwing following:
Seems like nginx is not able to translate the grpc-web request to valid http2 header frame binary format - it's missing the reserved bits (INBOUND DATA: streamId=1 padding=0 endStream=true length=84 bytes=4141414....) |
Beta Was this translation helpful? Give feedback.
-
@jmzwcn hey, are you sure that this actually works for grpc-web? |
Beta Was this translation helpful? Give feedback.
-
@jmzwcn hi 👋 We are considering moving from Envoy to Nginx for grpc-web, but not sure if it works for our use case. grpc-web docs says:
The configuration you provide uses Thank you. |
Beta Was this translation helpful? Give feedback.
-
I've just tried the proposed configuration. Although it works almost out-of-box, it seems far from a production-ready grade. First of all, after some tinkering around I was able to run the "hello world" example. But there were a few non-obvious moments. CORS headers are must have option. Those work fine - https://github.com/emart-io/cross/blob/main/pwa/nginx.conf#L20-L26. Another thing, ensure that you use the latest Nginx. I've tried with 1.18.0 and it didn't work due to the bug which was fixed in 1.19+. Finally, it worked with nginx version 1.25.5. What is serious is that nginx doesn't handle correctly the so-called "trailers" ("correctly" in the sense of gRPC/gRPC-Web interop, ofc), which compromises the whole scheme. I am wondering why no one else spotted this problem. To my guess, people only tried it with nodejs, where this is not the case. So, the servers, that are written in any other language (I've tested only with C++ and Python, but I bet that Go/Java are affected too), require the support of trailers, which is a basic requirement for gRPC. Browsers (so as gRPC-Web) don't support them, which is a problem. By default, the following error will appear on the server side:
This dirty hack fixes it:
Although it works with the hack, I have no idea how it will perform when the server decides to send trailing headers in responses. I bet it will jam the browser's HTTP parser and cause a network error. I haven't researched yet the condition for emitting trailing headers. Maybe when the data stream is long enough or in the presence of another stream. Or maybe it will never happen :). There is a code in Envoy, that handles trailing headers correctly - https://github.com/envoyproxy/envoy/blob/a7d3789c3eeda314c6a96be72485eb89a672a268/source/extensions/filters/http/grpc_web/grpc_web_filter.cc#L324-L365 - it moves them from "trailing area" into a body, if I understood it right. Nothing similar persists in nginx's All in all, despite the fact that solution works, one should use it will care. |
Beta Was this translation helpful? Give feedback.
-
It doesnt work for me, whenever i run i get
I run the react application as client and this is my nginx config
the server is the one in the example folder the hello world example and running locally in 9090 |
Beta Was this translation helpful? Give feedback.
-
Hey! I am pretty new to gRPC and nginx. I am trying to make an API Call from a sample website to the gRPC server. Whenever I make a call the gRPC web uses HTTP 1.1 protocol. How do I fix this? Can you guys guide me on this?
|
Beta Was this translation helpful? Give feedback.
-
Nginx is supported out of box, the config is very simple!
Keypoints:
More example, please refer to: https://github.com/emart-io/cross/blob/main/pwa/nginx.conf
Beta Was this translation helpful? Give feedback.
All reactions