private synchronized void createConnection() {
try {
endpoint = Remoting.createEndpoint("endpoint", OptionMap.EMPTY);
endpoint.addConnectionProvider("remote", new RemoteConnectionProviderFactory(), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE));
final IoFuture<Connection> futureConnection = endpoint.connect(new URI(hostUrl), OptionMap.create(Options.SASL_POLICY_NOANONYMOUS, Boolean.FALSE, Options.SASL_POLICY_NOPLAINTEXT, Boolean.FALSE), callbackHandler);
connection = IoFutureHelper.get(futureConnection, 30L, TimeUnit.SECONDS);
final EJBClientContext ejbClientContext = EJBClientContext.create();
ejbClientContext.registerConnection(connection);
this.clientContext = ejbClientContext;
} catch (IOException e) {
throw new RuntimeException(e);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}