envoyproxy - 如何从 NodeJS 服务器调用 grpc-web 代理
问题描述
我正在运行实现服务接口的 gRPC 服务器和允许客户端连接的 Envoy 代理,health.js
使用 webpack 构建并引用dist/main.js
到 HTML 文件中的以下 js 代码(文件)进行成功调用,它的工作
const { HealthCheckRequest, HealthCheckReply } = require("./protobuf/service_pb")
const { ProtoClient } = require("./protobuf/service_grpc_web_pb")
var client = new ProtoClient('http://localhost:8080');
var request = new HealthCheckRequest()
client.healthCheck(request, {}, (err, response) => {
console.log(response)
})
我想在NodeJS服务器而不是浏览器中执行此功能,实际上执行命令node health.js
时发生以下错误
...
ReferenceError: XMLHttpRequest is not defined
...
解决方案
目前没有对此的支持。您可以在https://github.com/grpc/grpc-node上通过我们的存储库创建功能请求
由于它实际上是不同的协议,因此需要编写新代码来支持它。
推荐阅读
- python - Celery '错误:没有节点在时间限制内回复'错误 - 如何调试?
- java - hibernate.cfg.xml 仅在使用已弃用的 buildSessionFactory() 时才被读取,而不是与 StandardServiceRegistryBuilder 一起使用
- javascript - 带有 Firebase 实时数据库和 VueFire 的 Vue.js 应用程序突然停止工作
- python - 断点和单步执行 Pandas/Python 中的代码
- php - 如何通过 DOMDocument 获取父元素和嵌套元素?
- serialization - 我可以在 Scio 中设置/取消设置默认编码器吗?
- python - 'NoneType' 对象在项目中没有属性“用户名”,该项目已经运行了一段时间
- core-data - CloudKit - 如何共享一组实体并允许创建新数据
- anaconda - 如何解决 Anaconda 和 Conda 更新 NoBaseEnvironmentError?
- vue.js - 在 Main.js 中导入 js-cookie 时出现问题