scala - Akka gRPC/HTTP Interop 给出 404
问题描述
我有一个运行 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
我应该怎么做才能确保两条路由之间的互操作?
解决方案
gRPC 使用 HTTP/2,所以试试
curl --http2 http://localhost:8080
它还应该摆脱最初的“标记捆绑...”消息。
推荐阅读
- android - 如何将方法添加到 Xamarin.Android 中的绑定库?
- spring-boot - Jackson 对象映射器 mixin 破坏了控制器的 springboot 列表响应
- android - 如何构建状态更新 UI
- google-sheets - 谷歌表格在数组中添加一个帮助列,而无需编辑原始源
- python-3.x - 当我使用 pandas concat 时数据框中的数据丢失
- php - 需要将“活动”类添加到自定义 WordPress 导航菜单
- spring - Spring Security OAuth2 在作为数组返回时无法解析范围
- elasticsearch - 弹性搜索:使用 query_string 的基数
- c++ - 我可以声明一个模板只接受具有同质签名的函数吗?
- vue.js - Vue.js/NativeScript:从父组件嵌套其他组件或从 app.js 有条件地加载组件?