Skip to content
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

bug: grpc-web plugin truncates trailing headers #10254

Closed
RogueJin opened this issue Sep 25, 2023 · 8 comments
Closed

bug: grpc-web plugin truncates trailing headers #10254

RogueJin opened this issue Sep 25, 2023 · 8 comments

Comments

@RogueJin
Copy link

Current Behavior

The response from grpc server has a trailing header but APISIX grpcweb plugin truncates it and causes client error.

WeChatWorkScreenshot_5b0438bc-c91a-43d9-be01-ec214bad4fd3

WeChatWorkScreenshot_862b930d-6e49-4acc-869f-de6de27ebbef

The related code of grpc-dotnet could be checked here:
https://github.com/grpc/grpc-dotnet/blob/46480fca2fccddb3391cf267004f281afe87571d/src/Grpc.Net.Client/Internal/GrpcProtocolHelpers.cs#L386
WeChatWorkScreenshot_543b9c2f-e7ad-496e-a179-5c7dd0bf2e00

Expected Behavior

Trailing headers could be reserved for client.

Error Logs

No response

Steps to Reproduce

  1. run APISIX via docker compose
  2. setup upstream grpcweb api
  3. config route
{
  "uri": "/*",
  "name": "grpcweb",
  "plugins": {
    "cors": {},
    "grpc-web": {}
  },
  "upstream_id": "479432631159620291",
  "status": 1
}
  1. curl
curl http://localhost:9080/xxxxxxxxx -X OPTIONS -v

Environment

  • APISIX version (run apisix version): 3.5.0
  • Operating system (run uname -a):

Linux 49c5eb4d90cd 5.15.49-linuxkit-pr #1 SMP PREEMPT Thu May 25 07:27:39 UTC 2023 aarch64 GNU/Linux

  • OpenResty / Nginx version (run openresty -V or nginx -V):
    nginx version: openresty/1.21.4.1
    built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
    built with OpenSSL 1.1.1s 1 Nov 2022
    TLS SNI support enabled

  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):

  • APISIX Dashboard version, if relevant:

  • Plugin runner version, for issues related to plugin runners:

  • LuaRocks version, for installation issues (run luarocks --version):

@shreemaan-abhishek
Copy link
Contributor

I'm not sure if APISIX modified the response because it's clear from the code that the only (response) body modification involved in the grpc-web plugin is base64 encoding:

https://github.com/shreemaan-abhishek/apisix/blob/88da2ecdd2a331d62f4c6d9849910d164ad33ead/apisix/plugins/grpc-web.lua#L135-L150

Can encoding lead to such an issue? 🤔

@RogueJin
Copy link
Author

The content-type is application/grpc-web and it uses binary encoding according to code.

content-type: application/grpc-web
grpc-accept-encoding: identity,gzip,deflate

https://github.com/shreemaan-abhishek/apisix/blob/88da2ecdd2a331d62f4c6d9849910d164ad33ead/apisix/plugins/grpc-web.lua#L43-L48

Just as you mentioned, the weird thing is that there is no explicit code modifying response body.

Any clue?

@Affanmir
Copy link

Facing the same issue, any update on this?

@kayx23 kayx23 changed the title bug: grpcweb plugin truncates trailing headers bug: grpc-web plugin truncates trailing headers Dec 1, 2023
@kayx23
Copy link
Member

kayx23 commented Dec 3, 2023

See projectcontour/contour#3233

@shreemaan-abhishek
Copy link
Contributor

continue discussion on #10573

@sheharyaar
Copy link
Contributor

@RogueJin , can you please check this and verify if changing from grpc-web to grpc-web-text works for you : #10573 (comment)

@RogueJin
Copy link
Author

we decided to give up grpc-web months ago since the issue, but I would check it in my spare time. thanks for the fixing anyway.

@RogueJin , can you please check this and verify if changing from grpc-web to grpc-web-text works for you : #10573 (comment)

@sheharyaar
Copy link
Contributor

@RogueJin , you can also checkout #10851 , if that fixes the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

5 participants