-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish interop information with grpc/grpc-web #162
Comments
@johanbrandhorst , |
Good idea, we will try to spend some time to clarify this. It would awesome if you could provide any findings you may already have. |
The last testing I did in this area was about a year ago when both the projects were very green indeed ;). My problem last time was getting their proxy up and running at all, but that is probably easier now. |
FYI grpc/grpc-web recently created a PR that implies (I haven't tested it) that their client is now compatible with this repos proxy: grpc/grpc-web#217 |
After much testing, it seems to me that the aforementioned PR doesn't make grpc/grpc-web client compatible with improbable-eng/grpc-web. The grpc/grpc-web client checks for the content-type header and wants it to be grpc-related ... whereas the improbable-eng/grpc-web proxy/library adds the content-type as a trailer. |
@tiramiseb very interesting! Do you mean to say you've been testing the other client against this proxy and found it broken? I've been meaning to write some compatibility tests myself but not got around to it yet. Could you go into more detail? Do you have a test repo? |
We want to avoid using a proxy, so we are using the grpc-web library directly. I have quickly looked at the source code for the proxy, it looks like it is directly importing the same library, so the behaviour I have with the library should be the same with the proxy. On the server side, we have implemented the library as explained in its README, listening on port 31337. There is no TLS involved. On the client side, after generating the service files with the following command:
... I am doing something like this: import {XXXClient} from './service_grpc_web_pb';
import {YYY} from './service_pb';
const XXXService = new XXXClient('https://localhost:31337', null, null);
[...]
var call = XXXService.feature(request, {}, function(err, response) {
console.log("GOT IT");
}); The behaviour I am experiencing is the following:
Then I have dug through the source code of both the improbable-eng/grpc-web server and the grpc/grpc-web client. On the server side, when The payload received by the browser is base64-encoded, after decoding and hexdump I have:
... which looks fine. Its headers are:
On the client side, the library checks the Content-Type header only, and returns without any further action when it does not start with I have tested and verified this behaviour by using the good ol' print-based debugging, I have cluttered both source codes with Before leaving yesterday, I noticed - I don't remember where - that the chuncked response may only be with HTTP/1.1, so today I'll try installing an nginx server with HTTP2+TLS in front of the backend server (which will be there in our production environment anyway)... |
I think what you're seeing here is that the grpc/grpc-web client does not support server-side streaming in the way you expect it to. The |
I don't plan to stream anything. I have just used the regular functions exposed by the generated code, as shown in the READMEs... It looks like the grpc/grpc-web client implements regular calls as if they were streams: https://github.com/grpc/grpc-web/blob/master/javascript/net/grpc/web/grpcwebclientbase.js#L72 |
Interesting - that makes sense since it's true for gRPC clients in general that a unary request is just a special case of a stream (with a single request and reply). I don't know if there's anything that proxy can do about that |
I can confirm I have the same behaviour with Nginx/HTTP2/TLS in front of the grpc-web server. |
So I've set up some compatibility tests between the two implementations at https://github.com/johanbrandhorst/grpc-web-compatibility-test. It shows largely that they're both compatible with one another in the simple cases (unary and server side streaming with |
I can confirm exactly the same behaviour as @tiramiseb describes. I am using Apparently, as @tiramiseb mentioned, when processing response from the server, grpc-web JS client checks for the If a gRPC service returns an error, then I ended up placing a hack in
It seems to work now. It seems like in certain cases |
The content-type header cannot be set when streaming responses to a fetch request AFAIK. When you say "grpc-web JS client" you mean the github.com/grpc/grpc-web client? I think this is a separate issue btw, could you please open another issue? |
Yes, that's the library I am referring to, the links that I've provided refer to this very library.
AFAIK, the sender should set adequate
No problem, I've opened the issue describing the problem with some additional findings. |
Now that github.com/grpc/grpc-web is publically available, we need clarity on how it interacts with the Improbable gRPC-web proxy, and how the Improbable grpc-web-client interacts with the grpc/grpc-web backend proxy.
Reference issue in grpc/grpc-web: grpc/grpc-web#91
The text was updated successfully, but these errors were encountered: