grpc / grpc-node

gRPC for Node.js
https://grpc.io
Apache License 2.0
4.51k stars 651 forks source link

Calling a gRPC service results in status code 2: "No status received" #1569

Open xiaozhongliu opened 4 years ago

xiaozhongliu commented 4 years ago

Problem description

Error occurs when calling a gRPC service which is behind the istio gateway: image

But it's ok if I use go client to request exactly the same gRPC service. Is there any difference on implementing go/node clients? Below are the results for all possible situations: go client => gRPC service ✅ node client => gRPC service ✅ go client => gateway => gRPC service ✅ node client => gateway => gRPC service ❌

Reproduction steps

server: any valid server gateway:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: gateway-isolated
  namespace: default
spec:
  selector:
    istio: ingressgateway
  servers:
    - hosts:
        - k8s-demo-grpc.internal.sample.com
      port:
        name: grpc
        number: 80
        protocol: GRPC
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: k8s-demo-grpc-isolated
  namespace: stage-c1
spec:
  hosts:
    - k8s-demo-grpc.internal.sample.com
  gateways:
    - default/gateway-isolated
  http:
    - route:
        - destination:
            host: k8s-demo-grpc

node client:

const proto = './helloworld.proto'
const address = 'k8s-demo-grpc.internal.sample.com:80'
const service = 'Greeter'
const method = 'sayHello'
const data = { name: 'world' }
const deadline = Date.now() + 1000

const grpc = require('grpc')
const protoLoader = require('@grpc/proto-loader')

const packageDefinition = protoLoader.loadSync(proto, {
    keepCase: true,
    longs: String,
    enums: String,
    defaults: true,
    oneofs: true,
})
const pack = grpc.loadPackageDefinition(packageDefinition).helloworld

function main() {
    const client = new pack[service](address, grpc.credentials.createInsecure())
    client[method](data, { deadline }, (err, response) => {
        if (err) return console.log(err)
        console.log('response:', response)
    })
}
main()

Environment

murgatroid99 commented 4 years ago

Can you try using @grpc/grpc-js instead of the grpc package in the client, to see if that has the same problem?

xiaozhongliu commented 4 years ago

@murgatroid99 Thanks for your reply. I noticed that @grpc/grpc-js has formal version now, I've tried with it and it resulted in code 13. I've also tried with node 12 and node 14, the same results for grpc and @grpc/grpc-js packages.

I think the situations I share indicate implementation on establishing a gRPC request may be different, do you need any other clue to further investigate? Plz tell me if you need.

menghanl commented 4 years ago

@xiaozhongliu Which version of gRPC-Go are you using?

And can you also try gRPC-Java? This should at least help us figure out who (Go or Core/node) is having the wrong behavior.

xiaozhongliu commented 4 years ago

@menghanl Sorry for the late reply. I tested with the latest grpc-go and grpc-java. The latest summary is as below, that indicates the node client may have the incorrect behavior.

go client => gRPC service ✅
java client => gRPC service ✅
node client => gRPC service ✅
go client => gateway => gRPC service ✅
java client => gateway => gRPC service ✅
node client => gateway => gRPC service ❌

Do you have an istio enabled k8s cluster to check on this issue?