Git Product home page Git Product logo

Comments (5)

mbush92 avatar mbush92 commented on August 11, 2024

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.

adhisimon avatar adhisimon commented on August 11, 2024

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.

mbush92 avatar mbush92 commented on August 11, 2024

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.

adhisimon avatar adhisimon commented on August 11, 2024

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.

mbush92 avatar mbush92 commented on August 11, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.