grpc-node icon indicating copy to clipboard operation
grpc-node copied to clipboard

server.bind () throwing error

Open estathop opened this issue 6 years ago • 17 comments

Problem description

I am trying to execute the simple example with greeter client and server. I downloaded all the affiliated files but when I am trying to run the greeter_server.js the following error throws

E1205 11:21:28.876231206 9372 server_chttp2.cc:40] {"created":"@1575537688.876213239","description":"No address added out of total 1 resolved","file":"../deps/grpc/src/core/ext/transport/chttp2/server/chttp2_server.cc","file_line":394,"referenced_errors":[{"created":"@1575537688.876211844","description":"Failed to add port to server","file":"../deps/grpc/src/core/lib/iomgr/tcp_server_custom.cc","file_line":404,"referenced_errors":[{"created":"@1575537688.876208981","description":"Failed to initialize UV tcp handle","file":"../deps/grpc/src/core/lib/iomgr/tcp_uv.cc","file_line":72,"grpc_status":14,"os_error":"address family not supported"}]}]}

Reproduction steps

Give very precise steps you've discovered to reproduce your problem. If possible and applicable, provide us with a repository we can clone that contains a reproduction case. Also if possible and applicable, please include a Dockerfile that exhibits the problem if it's specific to a certain environment. Bug reports with no reproduction steps will be closed.

Environment

  • Linux Ubuntu 18.04.3 LTS amd64
  • Node version: v12.13.1
  • Node installation method: Do not remember
  • Package name and version : [email protected]

Additional context

the line that throws the error in my code is this:

server.bind('0.0.0.0:50051', grpc.ServerCredentials.createInsecure());

I also tried 127.0.0.1:50051 but the result remains the same

estathop avatar Dec 05 '19 09:12 estathop

I suppose it has something to do with IPv6 not being configured/supported in my machine

estathop avatar Dec 05 '19 13:12 estathop

I think you are correct. That library automatically tries to convert to IPv6 addresses if possible and use those instead. Specifically, the issue is here: https://github.com/grpc/grpc/blob/master/src/core/lib/iomgr/tcp_server_custom.cc#L367-L376

murgatroid99 avatar Dec 05 '19 21:12 murgatroid99

I'm seeing a similar issue on grpc=1.24.2. Is there a way to have a nodejs gRPC server explicitly bind to ipv4 address?

mjpitz avatar Mar 20 '20 23:03 mjpitz

Seems like binding to the pod name might solve the problem if I'm reading this line right? https://github.com/grpc/grpc/blob/master/src/core/lib/iomgr/tcp_server_custom.cc#L384

mjpitz avatar Mar 20 '20 23:03 mjpitz

Alright, I've tried explicitly binding the pods IPv4 and I'm still getting this error. I tried a lot of things to remove the IPv6 semantic, but it seems like the underlying server still want's to bind to it.

mjpitz avatar Mar 23 '20 14:03 mjpitz

I managed to bypass this by migrating to grpc/grpc-js instead of using the c-core version.

mjpitz avatar Mar 27 '20 20:03 mjpitz

Any particular hurdle during the migration @mjpitz? I may try the same!

fbiville avatar Mar 30 '20 09:03 fbiville

Not really. Only API change was around using 'bindAsync' instead of 'bind'

mjpitz avatar Mar 30 '20 13:03 mjpitz

@mjpitz our migration has been more involved, but I confirm from our side as well that using grpc-js solves the issue

fbiville avatar Apr 09 '20 16:04 fbiville

@fbiville ah yeah. I figured coming from the generated code side of the world would be a bit more involved. I picked up on the proto-loader early on and it's made some things easier. I also write an async/await shim that makes some of the service interfaces easier to work with.

mjpitz avatar Apr 09 '20 23:04 mjpitz

Hello there , this is a very big issue for us as we are jailed with this particular NestJS version using this library. Do you know if there are any workarounds to make this work in an non IPv6 environment ?

nagaland88 avatar Nov 17 '20 19:11 nagaland88

@nagaland88 I think I was able to get around this for a little bit of time by binding to the "host" ip. If you're in kubernetes, it would be the pod ip, if you're in vanilla docker, the container ip. There are some things to keep in mind when binding to the host IP instead of to the wildcard address (specifically, how things dial your service).

mjpitz avatar Nov 18 '20 19:11 mjpitz

The grpc package is now deprecated, so we will not make changes to fix this. We recommend instead using @grpc/grpc-js, which does not have this issue.

murgatroid99 avatar May 07 '21 20:05 murgatroid99

hi, I am getting the very same issue using grpc/grpc-js ... which is wired... my address: 127.0.0.1:50052

XRarach avatar Jul 30 '21 11:07 XRarach

That has to be a different bug in grpc-js. Please file a different issue with details of the error you are encountering.

murgatroid99 avatar Aug 02 '21 15:08 murgatroid99

This bug is still valid, i am seeing this error in my local too

SyedUmerHasan avatar Feb 03 '22 10:02 SyedUmerHasan

If you experienced this bug in the grpc package, then as stated above, the package is deprecated and we will not be fixing it. If you are experiencing this bug in the @grpc/grpc-js package, it is actually a different bug, so please file another issue with the details.

murgatroid99 avatar Feb 03 '22 17:02 murgatroid99