If your application is set to start on boot then there is a chance that it will start executing before the network is ready. Add this simple check before you perform any critical network tasks.
if (!Network.isActive()) {
System.out.println("Waiting for network");
while (!Network.isActive()) {
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
ex.printStackTrace(System.err);
}
}
}
System.out.println("Network Ready");
Real-Time Mon - Fri, 8am - 4pm EST P: 724-933-9350 PureChat |
Always Available Contact Form sales@integpg.com support@integpg.com |