We are working on this issue, as a temporary solution consider adding an
ISystemListener to your
IClient instance and implement code which calls
IClient.reconnect() method in
onDisconnect(). You can find the
reconnect() example in the following fragment of Main.java of standalone API:
client.setSystemListener(new ISystemListener() {
private int lightReconnects = 10;
@Override
public void onStart(long processId) {
LOGGER.info("Strategy started: " + processId);
}
@Override
public void onStop(long processId) {
LOGGER.info("Strategy stopped: " + processId);
if (client.getStartedStrategies().size() == 0) {
System.exit(0);
}
}
@Override
public void onConnect() {
LOGGER.info("Connected");
lightReconnects = 10;
}
@Override
public void onDisconnect() {
LOGGER.warn("Disconnected");
if (lightReconnects > 0) {
LOGGER.info("TRY TO RECONNECT, reconnects left: " + lightReconnects);
client.reconnect();
--lightReconnects;
} else {
try {
// sleep for 5 seconds before attempting to reconnect
Thread.sleep(5000);
} catch (InterruptedException e) {
// ignore
}
try {
client.connect(jnlpUrl, userName, password);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
}
});