My job is developing software for network cameras for retail. One of the software packages that my team is developing is a web server that retrieves various reports created in HTML by the camera itself (which has its own built-in web server) and is stored on the camera. Then, our SOFTWARE WILL RECEIVE these reports from the camera and store them on a central web server.
While we are perfectly connecting the IP addresses of the cameras to our software, I am developing a simple Java class that will query the network and find all the cameras on the network.
The problem is that although it works very well on my PC and on my college computer, when we try to run it on a real web server that will host our software ... it works, but it says that everyone The subnet IP address is offline / unreachable EXCEPT for the IP gateway.
For example, if I started it from a PC or my colleague's PC, when connected to a closed local network, I get the following active IP addresses found along with a flag telling me whether his camera is or not. (the gateway is 192.168.0.1, the subnet mask is 255.255.255.0, which means the full range of 256 devices to look for)
IP:/192.168.0.1 Active:true Camera:false IP:/192.168.0.100 Active:true Camera:true <- this is camera 1 IP:/192.168.0.101 Active:true Camera:true <- this is camera 2 IP:/192.168.0.103 Active:true Camera:false <- my PC IP:/192.168.0.104 Active:true Camera:false <- this is our webserver
But for some reason, when starting the same program from the web server PC, using the same JRE, I get only the found
IP:/192.168.0.1 Active:true Camera:false
Now, my code, instead of listing through each IP in order in the main stream, instead creates a separate stream for each IP address being checked and starts them at the same time (otherwise, it will take no more than 21 minutes to time out a list with a timeout 5000 ms / IP). The main thread then restarts these IP scan threads every 15 seconds again and again.
I checked that all threads terminate on all PCs, there are no exceptions. It is even verified that not one of the threads is stuck. Each stream takes from 500 to 5050 ms from start to finish, and those flows that have active IP processing before (> 5000 ms), so I know that it correctly waits for 5000 ms in the ipAddr.isReachable (5000) method.
My colleague and I are stupid at the moment, while it seems that these active IP addresses are excellent when launched on our PCs, but do not receive a response from the PC web server.
We excluded problems with the firewall, problems with access to the administrator, etc. The only difference is that our web server is Embedded Win XP, and our PCs are Windows 7.
It surpassed us. Any ideas why?
Below is the code that starts each IP stream:
public void CheckIP() { new Thread() { @Override public void run() { try { isActive = ipAddr.isReachable(5000); if (isActive) { if (!isCamera) { isCamera = new IpHttpManager().GetResponse(ipAddr.toString()); } } else { isCamera = false; } } catch (Exception e) { e.printStackTrace(); } } }.start();
}
EDIT: Here is the code that builds each IP address to check after defining a range based on the gateway and subnet ...
for(int i=subMin; i<=subMax; i++) { byte[] ip = new byte[] {(byte)oct[0],(byte)oct[1],(byte)oct[2],(byte)i}; try { scanners[subCount] = new IpScan(InetAddress.getByAddress(ip)); subCount++; } catch (UnknownHostException e) { e.printStackTrace(); }}