javarubymultithreadingsocketsjruby

JRuby-1.7.19 UDPSocket "initialize: name or service not known" while scanning IP range


In my programming I'm scanning an IP range for devices that respond to snmp. I'm iterating through a list of IP addresses and putting each on into it's own thread and using the ruby gem snmp to test if the device responds to snmp.

The main program does the threading and is written in java, the networking is handled by a jruby jar. I'm using a thread pool of 10 threads. I'm after the first few threads run I start getting a "SocketError: initialize: name or service not known" on several of the threads when they try and setup a jruby UDPSocket. It's even showing the error on IP addresses that I know are snmp enabled. I've dug into the jruby implementation of UDPSocket and it uses the DatagramChannel class which is thread safe. I'm not quite sure what is causing this it almost seems like I'm only allowed to make so many UDP connections, I'm not sure if that's even true.


Solution

  • We did end up finding out what the issue for this was. Turns out it was not a JRuby issue at all. When scanning the IP range we found out that there is a limited number of datagram ports that can be opened in the JVM. That was the limit we were hitting. I believe there is a command to increase this limit but I was unable to track it down.