[英]Not able to connect to grpc from nodejs/python client
My grpc server is in go (go-micro), and it working fine, I have tested both via micro web
and go web app (iris).我的 grpc 服务器在 go (go-micro) 中,并且工作正常,我已经通过
micro web
和 go web 应用程序 (iris) 进行了测试。
This is a local grpc setup这是本地 grpc 设置
I keep getting this error ( Stream removed
)我不断收到此错误(
Stream removed
)
{ Error: 2 UNKNOWN: Stream removed
at new createStatusError ([projectROOT]/node_modules/grpc/src/client.js:64:15)
at [projectROOT]/node_modules/grpc/src/client.js:583:15
code: 2,
metadata: Metadata { _internal_repr: {} },
details: 'Stream removed' }
and sometimes I get this error ( Trying to connect an http1.x server
)有时我会收到此错误(
Trying to connect an http1.x server
)
{ Error: 14 UNAVAILABLE: Trying to connect an http1.x server
at new createStatusError ([projectROOT]/node_modules/grpc/src/client.js:64:15)
at [projectROOT]/node_modules/grpc/src/client.js:583:15
code: 14,
metadata: Metadata { _internal_repr: {} },
details: 'Trying to connect an http1.x server' }
const grpc = require('grpc');
const AuthPB = require('./auth_pb');
const AuthService = require('./auth_grpc_pb');
const AuthClient = new AuthService.AuthClient(
`localhost:59685`,
grpc.credentials.createInsecure()
);
function run(cb) {
const AuthTokenRequest = new AuthPB.AuthTokenRequest({
token: `some token`,
});
AuthClient.isLoggedIn(AuthTokenRequest, (err, authRes) => {
if(!err) return cb({status: 1});
cb({
status: 0,
err,
message: 'Not loggedin',
});
});
}
run(console.log);
Traceback (most recent call last):
File "app.py", line 15, in <module>
run()
File "app.py", line 11, in run
res = AuthStub.IsLoggedIn(atReq)
File "[python3.6-path]/site-packages/grpc/_channel.py", line 484, in __call__
return _end_unary_response_blocking(state, call, False, deadline)
File "[python3.6-path]/site-packages/grpc/_channel.py", line 434, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNKNOWN, Stream removed)>
. .
Traceback (most recent call last): File "app.py", line 15, in <module> run() File "app.py", line 11, in run res = AuthStub.IsLoggedIn(atReq) File "[python3.6-path]/site-packages/grpc/_channel.py", line 484, in __call__ return _end_unary_response_blocking(state, call, False, deadline) File "[python3.6-path]/site-packages/grpc/_channel.py", line 434, in _end_unary_response_blocking raise _Rendezvous(state, None, None, deadline) grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNKNOWN, Stream removed)>
import grpc import auth_pb2 import auth_pb2_grpc def run(): channel = grpc.insecure_channel('localhost:59685') AuthStub = auth_pb2_grpc.AuthStub(channel) atReq = auth_pb2.AuthTokenRequest(token='some token') res = AuthStub.IsLoggedIn(atReq) print("IsLoggedin: " + res.status) if __name__ == "__main__": run()
I had same error message when client tried create insecure connection but server use ssl当客户端尝试创建不安全的连接但服务器使用 ssl 时,我收到相同的错误消息
Try to replace尝试更换
grpc.credentials.createInsecure()
on在
grpc.credentials.createSsl()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.