亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

grpc 服務器顯示“未實現的服務錯誤”

grpc 服務器顯示“未實現的服務錯誤”

C#
侃侃爾雅 2023-05-13 15:53:34
我按照以下說明創建了一個 grpc 服務器和客戶端:https://learn.microsoft.com/en-us/aspnet/core/tutorials/grpc/grpc-start ?view=aspnetcore-3.0&tabs=visual-studio 。當我嘗試從客戶端調用服務時,客戶端顯示此錯誤消息:“發生一個或多個錯誤。(Status(StatusCode=Unknown, Detail="No status received"))"和服務器這個:info: Microsoft.AspNetCore.Hosting.Diagnostics[1]      Request starting HTTP/2 POST http://STEINI-PC/LocationService/GetLocations application/grpcinfo: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]      Executing endpoint 'gRPC - gRPC - Unimplemented service'info: Grpc.AspNetCore.Server.Internal.ServerCallHandlerFactory[1]      Service 'LocationService' is unimplemented.info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]      Executed endpoint 'gRPC - gRPC - Unimplemented service'info: Microsoft.AspNetCore.Hosting.Diagnostics[2]      Request finished in 51.812000000000005ms 200 application/grpc原型文件:syntax = "proto3";service EventService {    rpc GetEvents (Empty) returns (Events) {}    rpc GetEvent (Id) returns (Event) {}    rpc GetEventsByLocation (Id) returns (Events) {}    rpc AddEvent (Event) returns (Empty) {}    rpc UpdateEvent (Event) returns (Empty) {}    rpc DeleteEvent (Id) returns (Event) {}}service LocationService {    rpc GetLocations (Empty) returns (Locations) {}    rpc GetLocation (Id) returns (Location) {}    rpc AddLocation (Location) returns (Empty) {}    rpc UpdateLocation (Location) returns (Empty) {}    rpc DeleteLocation (Id) returns (Location) {}}service ParticipantService {    rpc GetParticipants (Empty) returns (Participants) {}    rpc GetParticipant (Id) returns (Participant) {}    rpc GetParticipantsFromEvent (Id) returns (Participants) {}    rpc AddParticipant (Participant) returns (Empty) {}    rpc UpdateParticipant (Participant) returns (Empty) {}    rpc DeleteParticipant (Id) returns (Participant) {}}message Empty {}message Id {    string id = 1;}
查看完整描述

4 回答

?
暮色呼如

TA貢獻1853條經驗 獲得超9個贊

進入 programs.cs 并添加您的服務。



// Configure the HTTP request pipeline.

app.MapGrpcService<GreeterService>(); // here's a service

app.MapGrpcService<UserAuthService>(); // another service i created

app.MapGrpcService<BusinessService>(); // also another service created


app.MapGet("/", () => "Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");


app.Run();


查看完整回答
反對 回復 2023-05-13
?
明月笑刀無情

TA貢獻1828條經驗 獲得超4個贊

我發現了問題。

我的問題是生成文件的不同命名空間,我手動編輯了這些文件。


查看完整回答
反對 回復 2023-05-13
?
森林海

TA貢獻2011條經驗 獲得超2個贊

如果您在原型中使用“包”,請確保服務器端與客戶端匹配。



查看完整回答
反對 回復 2023-05-13
?
aluckdog

TA貢獻1847條經驗 獲得超7個贊

只是為這個問題貢獻我自己的解決方案,這可能對那些在 C# 中使用代碼優先 grpc 的人有用。

我未能完全轉換現有的 GRPC 服務項目以采用代碼優先 GRPC 支持,特別是我的 program.cs 缺少對以下內容的調用:

builder.Services.AddCodeFirstGrpc();

我的代碼中仍然有替代方案,因此刪除了以下內容:

builder.Services.AddGrpc();

此外,我之前按照其他回復中的建議檢查了我的命名空間混淆代碼。我的 grpc 服務接口定義和服務實現是在不同的命名空間中聲明的,但是一旦使用 AddCodeFirstGrpc() 正確初始化,這不會導致代碼優先 grpc 失敗。


查看完整回答
反對 回復 2023-05-13
  • 4 回答
  • 0 關注
  • 330 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號