【问题标题】:Akka gRPC/HTTP Interop giving 404Akka gRPC/HTTP Interop 给出 404
【发布时间】:2021-10-06 11:23:30
【问题描述】:

我有一个应用程序运行 gRPC 服务和一个简单的 Akka HTTP 端点。我正在关注本指南:https://doc.akka.io/docs/akka-grpc/current/server/akka-http.html。问题:当卷曲 HTTP 端点时,我得到 404 未找到。我知道它找到了服务器,因为 Akka-HTTP/10.2.5 是响应头的服务器。

一些代码:

object Server extends App {
        val conf = ConfigFactory
            .parseString("akka.http.server.preview.enable-http2 = on")
            .withFallback(ConfigFactory.defaultApplication())
        val system = ActorSystem("Interop", conf)
        new Server(system).run()
}

class Server(system: ActorSystem) {
    def run() = {
        // implicit sys, ec...
        val grpcService: HttpRequest => Future[HttpResponse] = ServiceHandler(new Service())
        val greeter = get {
            pathEndOrSingleSlash {
                complete("I am alive")
            }
        }
        // lifted this line straight out of the guide
        val grpcRoute = { ctx => grpcService(ctx.request).map(RouteResult.Complete) }
        val route = concat(greeter, grpcRoute)
        val binding = Http().newServerAt("127.0.0.1", 8080).bind(route)
        binding
    }
}

当我取出 gRPC 路由时,greeter 端点按预期工作。否则,当我curl http://localhost:8080 时,我得到

*Mark bundle as not supporting multiuser
<HTTP/1.1 404 Not Found
<Server: akka-http/10.2.5
<other-stuff

我正在使用 akka-gRPC 2.0.0

我应该怎么做才能确保两条路由之间的互操作?

【问题讨论】:

    标签: scala akka http2 akka-http akka-grpc


    【解决方案1】:

    gRPC 使用 HTTP/2 所以试试

    curl --http2 http://localhost:8080
    

    它还应该去掉最初的“Mark bundle...”消息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-31
      • 2020-09-16
      • 1970-01-01
      • 2017-01-11
      • 1970-01-01
      相关资源
      最近更新 更多