我正在运行gRPC服务器,该服务器实现服务接口和一个Envoy代理,该代理使客户端可以连接以下js代码(文件health.js
),这些代码是使用webpack构建的,并将dist/main.js
引用到HTML文件中拨打成功电话就可以了
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
...
答案 0 :(得分:1)
目前对此不支持。您可以在https://github.com/grpc/grpc-node
的存储库上创建功能请求由于实际上是不同的协议,因此需要编写新代码以支持该协议。