我有一个运行gRPC服务的应用程序和一个简单的Akka HTTP端点。我遵循这个指南:https://doc.akka.io/docs/akka-grpc/current/server/akka-http.html。问题:当卷曲HTTP端点时,我得到404not found。我知道它找到了服务器,因为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路由时,欢迎端点按预期工作。否则,当我使用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
我应该怎么做才能确保两个路由之间的互操作性?
发布于 2021-07-31 14:17:10
gRPC使用超文本传输协议/2,所以尝试
curl --http2 http://localhost:8080它还应该去掉最初的"Mark bundle...“消息。
https://stackoverflow.com/questions/68599020
复制相似问题