将Postman与GRPC一起使用

发布于 2025-02-09 06:28:34 字数 1320 浏览 2 评论 0原文

我有以下“ Hello World” GRPC Serivice在AC#中工作,vs 2022 Console Client致电HTTP和HTTPS端点;但是,当使用邮递员用于Windows(VER 9.21.3)时,我会遇到错误。

原始:

service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings.
message HelloReply {
  string message = 1;
}

post http:// localhost:5046/enterer/sayhello

> RAW> {“名称”:“测试GRPC HTTP”}

Postman响应 - > “解析错误:服务器返回了错误的响应”

Postman控制台 - > “错误:解析错误:预期HTTP/” C#GRPC服务器控制台 - >无


帖子https:// localhost:7046/enterer/sayhello

> RAW> {“名称”:“测试GRPC HTTPS”} Postman响应 - > “错误:套接字挂起”

C#GRPC服务器控制台 - > “ TLS上的HTTP/2没有在HTTP/2仅端点上协商。”

有人在C#/VS2022/Postman堆栈中取得成功吗?

更新

我现在通过@laurentgabiot发布的链接创建我的请求: https://blog.postman.com/postman-now-now-now-now-supports-grpc/ < /a>

现在,我的两个http/https端点都会遇到相同的错误:

“错误:无效协议:https”

在其示例中,他们的端点是:“ Grpcb.in:9000”这意味着。不确定如何在VS2022/C#中执行此操作。

注意:我要留下我的原始错误(上图),以防其他人以与我相同的方式创建他们的请求。

I've got the following "hello world" gRPC serivice working in a c#, VS 2022 console client calling both http and https endpoints; but I get errors when using Postman for Windows (ver 9.21.3) calling the same endpoints.

proto:

service Greeter {
  // Sends a greeting
  rpc SayHello (HelloRequest) returns (HelloReply);
}

// The request message containing the user's name.
message HelloRequest {
  string name = 1;
}

// The response message containing the greetings.
message HelloReply {
  string message = 1;
}

post http://localhost:5046/Greeter/SayHello

body > raw > {"Name" : "testing grpc http"}

postman response -> "Parse Error: The server returned a malformed response"

postman console -> "Error: Parse Error: Expected HTTP/" c# grpc server console -> none


post https://localhost:7046/Greeter/SayHello

body > raw > {"Name" : "testing grpc HTTPS"} postman response -> "Error: socket hang up"

c# grpc server console -> "HTTP/2 over TLS was not negotiated on an HTTP/2-only endpoint."

Anyone having success with the c#/VS2022/Postman stack?

UPDATE

I'm now creating my request via the link posted by @LaurentGabiot here:
https://blog.postman.com/postman-now-supports-grpc/

and am now getting the same error for both of my http/https endpoints:

"Error: Invalid protocol: https"

In their sample, their endpoints are: "grpcb.in:9000" whatever that means. Not sure how to do that in Vs2022/c#.

Note: I'm leaving my original errors (above) in case someone else creates their request the same way that I did.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夕嗳→ 2025-02-16 06:28:34

只需在没有方案的情况下输入URL,即服务器URL,即localhost:5046

Just type the URL without scheme as the server URL, i.e. localhost:5046.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文