【发布时间】:2020-08-16 18:29:18
【问题描述】:
gRPC 服务(在 springboot 中开发)部署为 AWS linux (ec2) 上的 docker 容器。使用端口转发 -p6565:6565 启动 docker 映像。 现在通过笔记本电脑上的 BloomRPC 直接点击时,它可以工作:ec2.IP:6565 Package.Service.Method
在 Kong 配置的服务和路线:
{
"host": "ec2.IP",
"created_at": 1588403433,
"connect_timeout": 60000,
"id": "e657d8df-6247-458a-a8e8-bec00c41e03c",
"protocol": "grpc",
"name": "aws-grpc1",
"read_timeout": 60000,
"port": 6565,
"path": null,
"updated_at": 1588403433,
"retries": 5,
"write_timeout": 60000,
"tags": null,
"client_certificate": null
}
Route:
{
"strip_path": false,
"path_handling": "v0",
"updated_at": 1588403452,
"destinations": null,
"headers": null,
"protocols": [
"grpc",
"grpcs"
],
"created_at": 1588403452,
"snis": null,
"service": {
"id": "e657d8df-6247-458a-a8e8-bec00c41e03c"
},
"name": "aws-grpc1-route1",
"methods": null,
"preserve_host": false,
"regex_priority": 0,
"paths": [
"/grpc2"
],
"sources": null,
"id": "5739297e-3be7-4a0d-8afb-cfa8ed01cec2",
"https_redirect_status_code": 426,
"hosts": null,
"tags": null
}
现在通过 grpcurl 击中它 -> 它不起作用:
grpcurl -v -d "{}" -insecure ec2.ip:8443 package.service.pingMethod
Error invoking method "package.service.ping": target server does not expose service "package.service"
这是看起来相关的 kong 配置:
"proxy_listen": [
"0.0.0.0:8000 reuseport backlog=16384",
"0.0.0.0:8443 **http2** ssl reuseport backlog=16384"
],
所以这里是查询: (1) 8000 也可以为 https 配置为不安全 -> 通过在 kong-container 启动时传递一个 env KONG_PROXY_LISTEN 变量
-e "KONG_PROXY_LISTEN=0.0.0.0:8000 http2, 0.0.0.0:8443 http2 ssl"
这样做好吗?
(2) 如何开启服务器端反射?或者 /grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo 有什么用?
【问题讨论】:
标签: grpc api-gateway grpc-java kong