in code/src/main/java/Connection.java [44:95]
public void connect() throws JCoException {
if (!config.connected) {
final ExecutorService executor = Executors.newCachedThreadPool();
final Callable<Object> task = new Callable<Object>() {
public Object call() throws JCoException {
try {
System.out.println("Trying to connect...");
System.out.println();
final JCoDestination destination = JCoDestinationManager.getDestination(config.destination_name);
config.destination = destination;
System.out.println("RFC connection attributes:");
System.out.println(destination.getAttributes());
System.out.println("Connection established!");
System.out.println();
config.connected = true;
//reportUptime(true);
}
catch (final JCoException e) {
//reportUptime(false);
System.out.println(e);
throw new RuntimeException("Connection could not be established! Please verify the host & instance config in AWS Secrets Manager and make sure your server can be reached (e.g. adjust Security Group). You can force a function config reset, by passing '{ \"refresh\": \"true\" } ' as test/event parameters!");
}
return config.connected;
}
};
final Future<Object> future = executor.submit(task);
try {
final Object result = future.get(config.rfc_timeout, TimeUnit.SECONDS);
} catch (final TimeoutException ex) {
System.out.println(ex);
config.connected = false;
//reportUptime(false);
throw new RuntimeException("Connection could not be established! Please verify the host & instance config in AWS Secrets Manager and make sure your server can be reached (e.g. adjust Security Group). You can force a function config reset, by passing '{ \"refresh\": \"true\" } ' as test/event parameters!");
} catch (final InterruptedException e) {
// handle the interrupts
//System.out.println(e);
throw new RuntimeException(e);
} catch (final ExecutionException e) {
// handle other exceptions
//System.out.println(e);
throw new RuntimeException(e);
} finally {
future.cancel(true);
}
}
}