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

request help: grpc-transcode plugin converts http/json parameters abnormally #1991

Closed
zhoujun24 opened this issue Aug 4, 2020 · 11 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@zhoujun24
Copy link

Issue description

The grpc-transcode plugin, after the protocol conversion, the parameters obtained by the back-end service are inconsistent with the http request parameters

.proto:
syntax = "proto3";

package cmdb_api;

// The CmdbAPI service definition.
service CmdbAPI {
rpc GetHostIPs (IPsRequest) returns (IPsReply) {}
}

message UsageTable {
string usage = 1;
repeated string secusage = 2;
}

message IPsRequest {
repeated string region = 1;
repeated string idc = 2;
repeated UsageTable usagetables = 3;
}

message IPsReply {
repeated string ips = 1;
string message = 2;
}

Add a route:
curl http://127.0.0.1:9080/apisix/admin/routes/10000 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"methods": ["POST"],
"uri": "/CmdbAPI/GetHostIPs",
"service_protocol": "grpc",
"plugins": {
"grpc-transcode": {
"proto_id": "100",
"service": "cmdb_api.CmdbAPI",
"method": "GetHostIPs"
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:9096": 1
}
}
}'

image
image

Environment

  • apisix version (cmd: apisix version): 1.4
  • OS: CentOS 7.4
  • Golang: 1.13 protoc: 3.11.4
@membphis
Copy link
Member

membphis commented Aug 4, 2020

@nic-chen please take a look at this issue

@nic-chen
Copy link
Member

nic-chen commented Aug 5, 2020

@zhoujun24 could you have a try that use format form-data to send request, please ?

@zhoujun24
Copy link
Author

@nic-chen
image
image

The form-data format does not meet our application scenarios

@nic-chen
Copy link
Member

nic-chen commented Aug 5, 2020

@zhoujun24

I know where the problem is now.
Currently only basic data types are supported, and support for complex types needs to be added:
https://github.com/apache/apisix/blob/master/apisix/plugins/grpc-transcode/util.lua#L63

If you are interested in fixing it, welcome to pr, or I will deal with it on this weekend.

@membphis membphis added the bug Something isn't working label Aug 5, 2020
@zhoujun24
Copy link
Author

@nic-chen
Another question:
The response defined in .proto is a repeated string type. When the backend response data is empty, the http response data becomes {}, which should be []. You can see in the previous Issue description

I am a backend engineer. Although I am interested in APISIX, I have never used Lua. I usually develop projects in C/C++, Go and Python. If I want to fix the problem, I should learn first.

The doc link of the grpc-transcode plugin on the APISIX project homepage is incorrect, it should actually be https://github.com/apache/apisix/blob/master/doc/plugins/grpc-transcode.md

@membphis
Copy link
Member

membphis commented Aug 6, 2020

The doc link of the grpc-transcode plugin on the APISIX project homepage is incorrect,

can you supply a screen capture? I can not sure which link is wrong.

@zhoujun24
Copy link
Author

@membphis
It was fixed a few days ago, #1946

@membphis
Copy link
Member

membphis commented Aug 8, 2020

ok, close this issue

@membphis membphis closed this as completed Aug 8, 2020
@zhoujun24
Copy link
Author

@membphis
#1991, This bug is not fixed.

image
image

@membphis membphis reopened this Aug 8, 2020
@zhoujun24
Copy link
Author

zhoujun24 commented Aug 18, 2020

@nic-chen Hello, When will this issue be fixed?

  1. The grpc-transcode plugin, after the protocol conversion, the parameters obtained by the back-end service are inconsistent with the HTTP request parameters.
  2. The response defined in .proto is a repeated string type. When the backend response data is empty, the HTTP response data becomes {}, which should be []. You can see in the previous Issue description

@nic-chen nic-chen self-assigned this Aug 23, 2020
@nic-chen
Copy link
Member

@nic-chen Hello, When will this issue be fixed?

  1. The grpc-transcode plugin, after the protocol conversion, the parameters obtained by the back-end service are inconsistent with the HTTP request parameters.
  2. The response defined in .proto is a repeated string type. When the backend response data is empty, the HTTP response data becomes {}, which should be []. You can see in the previous Issue description

Sorry for the delay, it has been busy recently, I will fix it as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants