I am attempting to create a client session and then use it to send multiple
commands. Is this possible?
{noformat}
ConnectFuture connect = client.connect(cred.getUserName(),
socketAddress);
if (connect.await(10000)) {
session = connect.getSession();
if (session != null) {
session.addPasswordIdentity(cred.getPassword());
AuthFuture future = session.auth();
future.await(config.getConnectionTimeout());
if (future.isFailure()) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format(
"Login to %s with id '%s' failed",
socketAddress, cred.getUserName()));
session.close(false);
}
} else {
return session;
}
} else {
LOG.info(String.format("Unable to create session with
%s",
socketAddress));
}
=== snip ===
ClientChannel channel =
session.createChannel(Channel.CHANNEL_EXEC,
command.getSend());
ByteArrayOutputStream out = new ByteArrayOutputStream();
ByteArrayOutputStream err = new ByteArrayOutputStream();
channel.setOut(out);
channel.setErr(err);
channel.open().await(10000);
channel.waitFor(EnumSet.of(ClientChannelEvent.CLOSED), 0);
{noformat}
Basically I call the first part to create the session and then execute the
command in the second part. I process the results and depending on output
I run other commands by calling the second part again. (same session, and I
have closed the previous channel).
The issue I see is that the session is closed when the channel is closed.
The implementation is using the NIO2 packages.
I am not certiain if this is a bug,
a misconfiguraiton on my part,
or patently not possible.
Any assistance would be appreciated.
Claude Warren
--
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren