【发布时间】:2022-01-20 09:31:19
【问题描述】:
我是 gRPC 的新手。我的程序是用nuxtjs编写的,是一个简单的login page,它接收username和password并使用gRPC将其发送到服务器。
当我使用BloomRPC 提交请求时,一切都很好。但是在使用浏览器时,请求并没有发送到服务器。
我的auth 班级如下:
// auth.js
export default class {
constructor(vars) {
this.tokenKey = vars.tokenKey
this.proto = vars.proto
this.client = new vars.proto.AuthenticationClient('http://127.0.0.1:50051', null, null)
}
async loginRequest(user) {
const request = new this.proto.LoginRequest()
request.setUsername(user.username.trim().toLowerCase())
request.setPassword(user.password.trim())
return await this.client.login(request, {})
}
}
使用浏览器向服务器请求时会显示此错误,无论服务器是否已启动。
net ERROR_CONNECTION_REFUSED
message: 'Http response at 400 or 500 level'
...
我必须进行特定配置吗?
我只是想要一个配置提示。
更新:
This link 说你应该使用 Envoy。但我们为什么需要它?以及如何配置?
BloomRPC 截图:
【问题讨论】:
-
nuxt真的在运行并监听 5005 端口吗?它会记录什么吗? -
好像
127.0.0.1:5005实际上没有在听(另外,听localhost和听127.0.0.1不一样)。 -
@GiovanniEsposito 谢谢。我以前看过这个答案。投票赞成的问题和答案是由我完成的。我正在使用grpc-web,但它看起来有我不知道的配置。我需要阅读更多内容。
-
@Saeed 如果您找到解决方案,请在此处添加答案。可能非常有用!
-
@GiovanniEsposito 问题是请求没有到达服务器,我需要一个代理将请求从客户端发送到服务器。请看我的回答。
标签: javascript django nuxt.js grpc envoyproxy