Comments (5)
Its possible to get the IP address of the client that is making the request. You simply need to access the underlying HTTP server object. If you access the request event you can get the remote IP address.
For example:
let serverOptions = {
host:'192.168.1.101',
port: 6968,
}
let server = xmlrpc.createServer(serverOptions)
server.httpServer.on('request', (req)=>{
let incomingIPAddr = req.connection.remoteAddress
console.log('IP ADDRESS:', incomingIPAddr)
})
Yields on the console log:
IP ADDRESS 192.168.56.101
from node-xmlrpc.
Thanks @mbush92 , but what I need is ip address of requester on method call. In the scope of method handler
var serverOptions = {
port: 8081
};
var server = xmlrpc.createServer(serverOptions);
server.on('topUpReport', function (err, params, callback) {
// how can i get caller ip address here
.....
})
from node-xmlrpc.
The server.httpServer.on event fires everytime someone makes a request to the RPC server. It's just an event from the httpServer that the RPC server is built in top of. There's no need to put it inside a method call, leave it outside the method and it will handle assigning the incoming requesters IP address to a global variable.
We have several socket servers in other parts of our application and we use the same event to grab the incoming IP address to know how to retrieve data from our data store and serve it back
from node-xmlrpc.
Correct me if I'm wrong, but if I use server.httpServer.on outside method handler scope, I think it would not give me correct IP address if there are multiple requests near paralel at the same time from different IPs/clients.
from node-xmlrpc.
What we see on the socket side is that this is not the case, basically your methods only fire within an instance of the socket connection that belongs to a single requestor. They are making a socket connection, requesting what they want and then closing the connection when they are done. I have not hammered the RPC library we are building yet with multiple fast paced requestors but the TCP socket version of the library was handling dozens of requestors firing every second when we did some of our load testing.
from node-xmlrpc.
Related Issues (20)
- Emoji in string raises error HOT 2
- CDATA on using '&'
- Why: Response has more than one param
- Uncaught TypeError: stream.setEncoding is not a function HOT 2
- Specifying number as long int when calling method HOT 1
- Add query to path on client side. HOT 1
- createClient returned object without methodCall
- trying XML RPC client with an https request HOT 2
- Error: ECONNRESET
- Is this project still maintained? HOT 3
- No way to set error handler on http/https server before listen is called
- Add info on request headers to readme
- How to tunnel through a proxy
- XMLRPC not resolve https/https HOT 4
- Bug in offset when parsing iso8601 date/time
- xmlrpc request with digest authentication in nodejs
- date formatter:decodeIso8601
- How do I enable CORS HOT 1
- this library still under maintenance? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-xmlrpc.