grpc - 如何向 gRPC-JSON 转码器端点提交请求?
问题描述
按照这个(我认为准确): https ://www.envoyproxy.io/docs/envoy/latest/configuration/http_filters/grpc_json_transcoder_filter
我正在遵循文档中的配置,并且我的 gRPC 服务已打开:50051
,并且 gRPC-JSON 转码器正在侦听:51051
.
我能够针对转码器提交 gRPC 请求:
grpcurl \
--plaintext \
--import-path=${HELLOWORLD} \
--import-path=${GOOGLEAPIS} \
--proto=helloworld/helloworld.proto \
-d '{"name":"Freddie"}' \
:51051 \
helloworld.Greeter/SayHello
{
"message": "Hello Freddie"
}
但我无法确定如何正确提交 REST 请求:
curl \
--request GET \
--header "Content-Type: application/json" \
--data '{"name":"Freddie"}' \
http://0.0.0.0:51051/helloworld.Greeter/SayHello
curl \
--header "Content-Type: application/json" \
--data '{"name":"Freddie"}' \
http://0.0.0.0:51051/say
curl \
--request GET \
--header "Content-Type: application/json" \
http://0.0.0.0:51051/say?name=Freddie
我尝试过使用|不使用标题,使用--insecure
和https,使用--request POST
和--request GET
所有都没有成功。
所有结果:
upstream connect error or disconnect/reset before headers. reset reason: remote reset
也希望获得有关调试此类问题的指导。Envoy 没有将任何与这些请求对应的标准输出记录到标准输出中,并且管理控制台也没有包含(明显的)解释。
谢谢!
解决方案
嗯...我在另一台机器上重新制作了解决方案,它可以工作:
工作变体:
curl \
--header "Content-Type: application/json" \
http://localhost:51051/say?name=Frederik
{
"message": "Hello Frederik"
}
curl http://localhost:51051/say?name=Frederik
{
"message": "Hello Frederik"
}
非工作(不正确)变体:
curl \
--header "Content-Type: application/grpc" \
http://localhost:51051/say
curl \
--data '{"name":"Henry"}' \
http://localhost:51051/say
upstream connect error or disconnect/reset before headers. reset reason: remote reset
推荐阅读
- react-admin - 如何使用演示左侧显示的可折叠菜单?
- spring-boot - 如何修复“在根项目'genie-voucher-module'中找不到任务'build'”
- php - 使用 PhpSpreadsheet 从字符串创建 CSV 文件
- c# - 多线程和随机的奇怪行为
- excel - 为什么不能在 MS Excel 中重命名附件?
- android - 切换到插件 android gradle 3.3 时构建项目 io.realm.DefaultRealmModule 时出错
- angular - 用户单击按钮后,将数组以角度传递到下一页
- android - 我该如何解决这个错误?(我有 3 个 xml 文件和 1 个 java 类文件)
- python - 没有切片和导入的滚动/滑动窗口迭代器?
- c# - 在 C# 中,对于长音频,Speaker Diarization 始终返回零