Linked Questions

Popular Questions

Node.js dgram, making validating response

Asked by At

I'm setting up a small program to send radius disconnect messages and validating whether it succeeded or failed.

I currently have it setup to send the messages and get a response, my question is, what if there is a delay in the response, how can I validate the response came from the correct request?

var packet = {
code: "Disconnect-Request",
secret: secret,
identifier: id,
attributes: [
    ['User-Name',user.username],
    ['Framed-IP-Address',record.framedipaddres],
]};
var encoded = radius.encode(packet);

client.send(encoded, 0, encoded.length, 3799, n.nasIP,function (err, res) {
if (err) {
    console.log('err',err)
} else {
    console.log('res',res)
    console.log(res)
}});



client.on('listening', function () {
var address = client.address();
console.log('UDP Server listening on ' + address.address + ":" + address.port);});

client.on('message', function (message, remote) {
console.log('got message')
console.log(message.readInt8())});

So, just to be 100% clear. I am getting the response back from the client and the message is going through, however, if I start sending many of these messages together, how will my server know which response matched which request? Ideally I would have liked client.send to have a callback with the response, but thats not how it worked?

Related Questions