Hello again,
I use context.getExecutionManager to create the execution manager “exe”, and HeartBeatDetector (listen for heartbeat every 30sec) which implements Runnable interface:
[code] public void beginRestart() {
logger.warn("Beginning reconnect to antenna: " + name);
exe.unRegister(“heartbeat monitor”,“heartbeat name”); //temporarily stop seeking a heartbeat
restart();
}
public void restart(){//attempt to connect to the LRS again with the same info
logger.warn("Attempting to reconnect to antenna " + name);
try{
clientSocket = new Socket(ip_address, port);
outToServer = new DataOutputStream(clientSocket.getOutputStream());
inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
clientSocket.setSoTimeout(2000);//reads will only wait 2 seconds before throwing a timeout exception
System.out.println(inFromServer.readLine());
outToServer.writeBytes(
"<Login user=\"anon\" "
+"passwd=\"anon\" "
+"services=\"NetPage:2.0;Config:1.0;Heartbeat:1.0\"/>" + "\n\r");
System.out.println(inFromServer.readLine());
heartbeat= new HeartbeatDetector(inFromServer, name, this);
logger.info("Successfully reconnected to antenna: "+name);
exe.register("heartbeat monitor","heartbeat name",heartbeat, 30000); //re-register the heartbeat task on successful connection
return; //successfully reconnected
}catch(Exception e){
logger.error("Unable to restart connection to antenna " + name + ". "+e.toString());
restart();//failed to reconnect, try again
}
}[/code]
but the problem is that some of the logger prints are not showing up in the logs.
Basically, the code itself works (continuously try to reconnect to the hardware until the connection becomes available again), but some of the logger prints are not showing up in the logger (as shown in attached image). Also, the logs are appearing out of order (Heartbeat should timeout first, then antenna should reconnect)
Could this have something to do with the execution manager? Why could this be this happening?