question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to get client IP address with node grpc

See original GitHub issue

Earlier I used below code to get the client IP on express js-

req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress```

would like to know what is the way to get IP of client with grpc node application. I tried getPeer() which gives always ipv4:127.0.0.1:33944 even when API call is from outside.

Does something equivalent to below go code work?call.getAttributes().get(Grpc.TRANSPORT_ATTR_REMOTE_ADDR).toString();

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
murgatroid99commented, Aug 19, 2020

I have published version 1.1.4 with that change, so getPeer should now work.

0reactions
aleneumcommented, Aug 18, 2020

Hello @murgatroid99,

any update when ServerUnaryCallImpl.getPeer() will be available in grpc-js? Are the failed build jobs in #1526 caused by configuration/invokation issues or actual failing tests? The logs seems to be empty and the PR’s changes don’t appear to be too complex.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to get client IP address with node grpc - Stack Overflow
You can get the client IP and port by: const SayHello = async function (call, callback) { const IPandPort = call.
Read more >
Basics tutorial | Node - gRPC
This tutorial provides a basic Node.js programmer's introduction to working with gRPC. By walking through this example you'll learn how to:.
Read more >
Building a gRPC Client and Server with Node.js
Following is the list: — server() It will create the server. — bindAsync() will specify the address and port to listen to the...
Read more >
How to get a client IP Address in Node.js (6 ways) - Abstract API
How to get a client IP Address in Node.js (6 ways) · 1. Retrieve User IP Address From the Request Object's Socket Property...
Read more >
gRPC service in Node.js: Tutorial, Examples and Best practices
A gRPC service contains, the server, protocol buffer, and the client. The server has the procedures or subroutines or methods that perform ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found