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

help request: how to proxy http+pb #11260

Open
snowleopard331 opened this issue May 16, 2024 · 8 comments
Open

help request: how to proxy http+pb #11260

snowleopard331 opened this issue May 16, 2024 · 8 comments

Comments

@snowleopard331
Copy link

snowleopard331 commented May 16, 2024

Description

我想使用http+pb的方式进行请求,但是打开grpc-transcode插件后,无论json/pb都可以请求到,但是返回的始终是json,我的需求是返回pb。请求头中的accept也设置过,但是都没用,以下是我的路由配置:

{
"uri": "/HelloWorld",
"name": "HelloWorld",
"desc": "HelloWorld接口,测试连通性",
"methods": [
"POST"
],
"plugins": {
"elasticsearch-logger": {
"batch_max_size": 1000,
"buffer_duration": 60,
"endpoint_addr": "http://xxxxxxxxxx",
"field": {
"index": "apisixlog"
},
"inactive_timeout": 5,
"max_retry_count": 0,
"name": "elasticsearch-logger",
"retry_delay": 1,
"ssl_verify": true,
"timeout": 10
},
"grpc-transcode": {
"_meta": {
"disable": false
},
"deadline": 0,
"method": "HelloWorld",
"pb_option": [
"enum_as_name",
"int64_as_number",
"no_default_values",
"disable_hooks"
],
"proto_id": "xxxxxxxxxxxx",
"service": "xxxxxxxxxx",
"show_status_in_body": false
},
"jwt-auth": {
"_meta": {
"disable": true
},
"cookie": "jwt",
"header": "authorization",
"hide_credentials": false,
"query": "jwt"
}
},
"upstream": {
"retries": 3,
"timeout": {
"connect": 6,
"send": 6,
"read": 6
},
"type": "chash",
"hash_on": "header",
"key": "USERID",
"scheme": "grpc",
"discovery_type": "nacos",
"discovery_args": {
"group_name": "xxxxxxxxx",
"namespace_id": "xxxxxxxxxxxxx"
},
"pass_host": "pass",
"service_name": "providers:kiwi.domainServer.example::",
"keepalive_pool": {
"idle_timeout": 60,
"requests": 1000,
"size": 320
},
"retry_timeout": 1
},
"status": 1
}

Environment

  • APISIX version (run apisix version):3.6.0
  • Operating system (run uname -a): Linux localhost.localdomain 4.18.0-513.9.1.el8_9.x86_64 change: added doc of how to load plugin. #1 SMP Wed Nov 29 18:55:19 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • 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):
@kayx23
Copy link
Member

kayx23 commented May 20, 2024

grpc-transcode is for transcoding between regular HTTP requests and gRPC, so it is expected that the upstream response is returned in JSON.

It sounds like you are not looking for any transcoding but to have APISIX proxy for your request to gRPC upstream service, is that correct?

@snowleopard331
Copy link
Author

grpc-transcode is for transcoding between regular HTTP requests and gRPC, so it is expected that the upstream response is returned in JSON.

It sounds like you are not looking for any transcoding but to have APISIX proxy for your request to gRPC upstream service, is that correct?

At present, I am using APISIX to proxy my upstreams, and the client uses JSON as the HTTP body. Currently, grpc-transcode is enabled, so the client's input and output are both in JSON format. Now the client wants to use protobuf as the input and output, but I don't know how to configure it. I have tried some solutions, but none have been successful; using HTTP+PB requests, the upstream can receive and process them, but APISIX always returns JSON to the client. What I want is a route configuration that can return protobuf. Thanks

@kayx23 kayx23 changed the title help request: 如何正确配置http+pb的请求方式 help request: how to proxy http+pb May 23, 2024
@kayx23
Copy link
Member

kayx23 commented May 23, 2024

APISIX always returns JSON to the client. What I want is a route configuration that can return protobuf.

I'm not aware if APISIX can do this. @shreemaan-abhishek thoughts?

@shreemaan-abhishek
Copy link
Contributor

shreemaan-abhishek commented Jun 2, 2024

no there is no such feature. do you mean to say that upstream returns PB but APISIX modifies it to JSON?

@snowleopard331
Copy link
Author

no there is no such feature. do you mean to say that upstream returns PB but APISIX modifies it to JSON?

No. All PB. No JSON. Do you know how to config APISIX route? Send PB and receive PB. Thank you.

@shreemaan-abhishek
Copy link
Contributor

No. All PB. No JSON.

I meant to ask, does the upstream return JSON even when not using APISIX?

@snowleopard331
Copy link
Author

No. All PB. No JSON.

I meant to ask, does the upstream return JSON even when not using APISIX?

upstream return pb, protocol is grpc

@shreemaan-abhishek
Copy link
Contributor

@snowleopard331, can you prepare a github gist/repo with a self contained example to reproduce this issue? I will take a look at this when I am free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants