kong grpc gateway网关插件报failed to transcode .proto错误是什么原因?
我的grpc服务是 127.0.0.1:8882 或 192.168.0.13:8882
我的Kong配置的服务与路由:
#services:
{
"tags":
[],
"ca_certificates": null,
"read_timeout": 60000,
"write_timeout": 60000,
"host": "192.168.0.13",
"tls_verify": null,
"created_at": 1630458681,
"tls_verify_depth": null,
"retries": 5,
"path": null,
"updated_at": 1630458698,
"id": "51573882-ac30-4bd5-ab99-5a94ff369584",
"name": "monitor-grpc",
"connect_timeout": 60000,
"client_certificate": null,
"protocol": "grpc",
"port": 8882
}
#route:
{
"next": null,
"data":
[
{
"headers": null,
"hosts": null,
"request_buffering": true,
"response_buffering": true,
"service":
{
"id": "51573882-ac30-4bd5-ab99-5a94ff369584"
},
"snis": null,
"https_redirect_status_code": 426,
"preserve_host": false,
"protocols":
[
"http",
"https"
],
"created_at": 1630468867,
"updated_at": 1630470535,
"path_handling": "v1",
"paths":
[
"/",
"/env_monitor_srv"
],
"name": "grpc-route",
"sources": null,
"id": "a5e3dea3-d216-477c-84c1-e7d505228f2d",
"methods": null,
"destinations": null,
"regex_priority": 0,
"strip_path": true,
"tags": null
}
]
}
#grpc gateway plugin:
{
"next": null,
"data":
[
{
"consumer": null,
"protocols":
[
"grpc",
"grpcs",
"http",
"https"
],
"created_at": 1630459281,
"tags": null,
"enabled": true,
"service":
{
"id": "51573882-ac30-4bd5-ab99-5a94ff369584"
},
"route": null,
"id": "65a074cb-eba4-4b86-9e98-c68c9f10e9a0",
"config":
{
"proto": "/usr/local/kong/protoc/kong-grpc.proto" //这个是 容器内地址,docker cp进去的
},
"name": "grpc-gateway"
}
]
}
然后我的kong-grpc.proto文件是:
syntax = "proto3";
option go_package = "/env_monitor_srv";
package env_monitor_srv;
service EnvMonitorSrv {
rpc GetContent(GetContentReqMsg) returns (GetContentRepMsg) {
option (google.api.http) = {
get: "/v1/content/{keyname}"
additional_bindings {
get: "/v1/content/test/{keyname}"
}
post: "/v1/content/{keyname}"
body: "*"
}
}
}
//配置文件请求API
message GetContentReqMsg
{
string keyname = 1;
}
message EtcdContentBody
{
string key =1;
int32 version = 2;
string update_time = 3;
string content = 5;
}
//配置文件响应API
message GetContentRepMsg
{
int32 code = 1;
string msg = 2;
EtcdContentBody data = 3;
}
//只在文件内容API
message SaveContentReqMsg
{
string keyname = 1;
string content = 2;
}
//响应
message SaveContentRepMsg
{
int32 code = 1;
string msg = 2;
}
然后我访问网关报failed to transcode .proto file Unknown path "/env_monitor_srv/v1/content/keyname"的错:
$ curl "http://127.0.0.1:8000/env_monitor_srv/v1/content/keyname" -i
HTTP/1.1 400 Bad Request
Date: Wed, 01 Sep 2021 06:07:57 GMT
Connection: keep-alive
Access-Control-Allow-Origin: *
Content-Length: 82
X-Kong-Response-Latency: 2
Server: kong/2.5.0
failed to transcode .proto file Unknown path "/env_monitor_srv/v1/content/keyname"
为啥 ?哪里出问题了?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论