Cysharp / GrpcWebSocketBridge

Yet Another gRPC over HTTP/1 using WebSocket implementation, primarily targets .NET platform.
MIT License
77 stars 12 forks source link

How to use it with yarp? #21

Closed OdericoOfficial closed 11 months ago

OdericoOfficial commented 11 months ago

my yarp configuration.:

        "ReverseProxy": {
          "Routes": {
            "seserver-statements": {
              "ClusterId": "seserver-statements-cluster",
              "Match": {
                "Path": "/statements/{**catch-all}"
              }
            },
            "seserver-auth": {
              "ClusterId": "seserver-auth-cluster",
              "Match": {
                "Path": "/auth/{**catch-all}"
              }
            }
          },
          "Clusters": {
            "seserver-statements-cluster": {
              "Destinations": {
                "statements": {
                  "Address": "http://seserver-statements"
                }
              }
            },
            "seserver-auth-cluster": {
              "Destinations": {
                "auth": {
                  "Address": "http://seserver-auth"
                }
              }
            }
          }
        }

two servers both use grpcwebsocketbridge. but when i call the test function like this:

        var channel = GrpcChannel.ForAddress("http://localhost:5104/statements", new GrpcChannelOptions()
        {
            HttpHandler = new GrpcWebSocketBridgeHandler()
        });

        var client = new Test.TestClient(channel);
        var response = await client.HelloWorldAsync(new HelloWorldRequest { Message = "Hello World" });

       Console.WriteLine(response.Message);

it return 404. all applications use .net 7

OdericoOfficial commented 11 months ago

i solve this problem by https://learn.microsoft.com/en-us/aspnet/core/grpc/troubleshoot?view=aspnetcore-7.0#calling-grpc-services-hosted-in-a-sub-directory