Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js: Disable UDP DNS lookup and use the given IP instead

Tags:

node.js

dns

udp

I have a simple CentOS node.js server that is supposed to consume high frequency UDP messages and then forward them to another service.

Trouble is that dgram.send does a DNS lookup on EVERY call. This DNS lookup is both slowing down the processing of the messages and occasionally getting the DNS server to blacklist the node.js host server thinking it's getting DOS'd.

The question is: how do I send a UDP packet in node.js WITHOUT incurring a DNS lookup?

Thanks for the time.

like image 506
James Avatar asked Nov 14 '22 12:11

James


1 Answers

Glancing through the code for Node, it looks like you can pass an IP address to dgram.send and it won't do anything with DNS. Is it possible to look up or cache your IPs manually and then pass them to the send method?

like image 147
Michelle Tilley Avatar answered Jan 31 '23 10:01

Michelle Tilley