if (this.pluginInfo != null)
this.clientAddress.setPluginInfoParameters(this.pluginInfo.getParameters());
if (log.isLoggable(Level.FINER)) log.finer("Entering connectLowlevel(), connection with raw socket to server, plugin setting is: " + this.pluginInfo.dumpPluginParameters());
this.socketUrl = new SocketUrl(glob, this.clientAddress);
if (this.socketUrl.getPort() < 1) {
String str = "Option dispatch/connection/plugin/socket/port set to " + this.socketUrl.getPort() +
", socket client not started";
log.info(str);
throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION_ADDRESS, ME, str);
}
this.localSocketUrl = new SocketUrl(glob, this.clientAddress, true, -1);
// SSL support
boolean ssl = this.clientAddress.getEnv("SSL", false).getValue();
if (log.isLoggable(Level.FINE)) log.fine(clientAddress.getEnvLookupKey("SSL") + "=" + ssl);
try {
if (this.useRemoteLoginAsTunnel) {
String entryKey = SocketExecutor.getGlobalKey(this.clientAddress.getSessionName());
Object obj = glob.getObjectEntry(entryKey);
if (obj != null && obj instanceof org.xmlBlaster.protocol.socket.HandleClient) {
org.xmlBlaster.protocol.socket.HandleClient h = (org.xmlBlaster.protocol.socket.HandleClient)obj;
this.sock = h.getSocket();
// TODO: HandleClient.closeSocket() can set sock = null!
if (this.sock != null) {
log.info(getLoginName() + " " + getType() + " entryKey=" + entryKey + " global.instanceId=" +glob.getInstanceId() + "-" + glob.hashCode() + (ssl ? " SSL" : "") +
" client is reusing existing SOCKET '"+this.sock.getInetAddress().getHostAddress() + ":" + this.sock.getPort()+ "' configured was '" +
this.socketUrl.getUrl() +
"', your configured local parameters are localHostname=" + this.localSocketUrl.getHostname() +
" on localPort=" + this.localSocketUrl.getPort() + " useUdpForOneway=" + this.useUdpForOneway +
"', callback address is '" + this.sock.getLocalAddress().getHostAddress() + ":" + this.sock.getLocalPort() + "'");
}
else {
log.severe(getLoginName() + " " + getType() + " " + getLocalSocketUrlStr()
+ " Didn't expect null socket for sessionName="
+ this.clientAddress.getSessionName() + ": Removing entryKey=" + entryKey + " global.instanceId=" +glob.getInstanceId() + "-" + glob.hashCode() + ": " + Global.getStackTraceAsString(null));
glob.removeObjectEntry(entryKey);
}
}
else {
// instance of dummy string: no HandleClient available, remote node has not yet connected
String str = "Connection to xmlBlaster server failed, no established socket to reuse found entryKey=" + entryKey;
if (log.isLoggable(Level.FINE)) log.fine(str);
throw new XmlBlasterException(glob, ErrorCode.COMMUNICATION_NOCONNECTION, ME, str);
}
}
else {
if (ssl) {
this.sock = this.socketUrl.createSocketSSL(this.localSocketUrl, this.clientAddress);
}
else {
if (this.localSocketUrl.isEnforced()) {
this.sock = new Socket(this.socketUrl.getInetAddress(), this.socketUrl.getPort(),
this.localSocketUrl.getInetAddress(), this.localSocketUrl.getPort());
}
else {
if (log.isLoggable(Level.FINE)) log.fine("Trying socket connection to " + socketUrl.getUrl() + " ...");
this.sock = new Socket(this.socketUrl.getInetAddress(), this.socketUrl.getPort());
}
}
if (this.localSocketUrl.isEnforced()) {
log.info(getType() + (ssl ? " SSL" : "") +
" client connected to '" + this.socketUrl.getUrl() +
"', your configured local parameters are localHostname=" + this.localSocketUrl.getHostname() +
" on localPort=" + this.localSocketUrl.getPort() + " useUdpForOneway=" + this.useUdpForOneway +
"', callback address is '" + this.sock.getLocalAddress().getHostAddress() + ":" + this.sock.getLocalPort() + "'");
}
else {
// SocketUrl constructor updates client address
this.localSocketUrl = new SocketUrl(glob, this.sock.getLocalAddress().getHostAddress(), this.sock.getLocalPort());
this.clientAddress.setRawAddress(this.socketUrl.getUrl());
log.info(getType() + (ssl ? " SSL" : "") +
" client connected to '" + socketUrl.getUrl() +
"', callback address is '" + this.localSocketUrl.getUrl() +
"' useUdpForOneway=" + this.useUdpForOneway + " clientAddress='" + this.clientAddress.getRawAddress() + "'");