问题
I'm working with a GRPC service hosted with HTTPS and self-signed cert. When I connect using syntax like:
const client = new productService('https://grpc-server-xxx.com:9090',
grpc.credentials.createInsecure())
I am getting the error like this
{ Error: 14 UNAVAILABLE: DNS resolution failed
at Object.exports.createStatusError (C:\grpc\node_modules\grpc\src\common.js:91:15)
at Object.onReceiveStatus (C:\grpc\node_modules\grpc\src\client_interceptors.js:1209:28)
at InterceptingListener._callNext (C:\grpc\node_modules\grpc\src\client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (C:\grpc\node_modules\grpc\src\client_interceptors.js:618:8) at callback (C:\grpc\node_modules\grpc\src\client_interceptors.js:847:24)code: 14,metadata: Metadata { _internal_repr: {}, flags: 0 },details: 'DNS resolution failed'
Anyone help me how can I resolve the issue.
Note: My OS is Windows 10, nodejs -- v10.16.0, GRPC
回答1:
The gRPC library does not recognize the https://
scheme for addresses, so that target name will cause it to try to resolve the wrong name. You should instead use grpc-server-xxx.com:9090
or dns:grpc-server-xxx.com:9090
or dns:///grpc-server-xxx.com:9090
. More detailed information about how gRPC interprets channel target names can be found in this documentation page.
来源:https://stackoverflow.com/questions/62108070/grpc-nodejs-dns-resolution-failed