session.connect(SESSION_CONNECT_TIMEOUT);
session.setTimeout(10000);
- try {
-// session.setServerAliveCountMax(0); // If this is not set to '0', then socket timeout on all reads will not work!!!!
- channel = session.openChannel("subsystem");
- ((ChannelSubsystem)channel).setSubsystem("netconf");
- netconfAdapter = new NetconfAdapter(channel.getInputStream(), channel.getOutputStream());
- channel.connect(CHANNEL_CONNECT_TIMEOUT);
- hello(connectionDetails.getCapabilities());
- } catch(Exception e) {
- disconnect();
- throw e;
- }
+
+ createConnection(connectionDetails);
+
} catch(Exception e) {
String message = EELFResourceManager.format(Msg.CANNOT_ESTABLISH_CONNECTION, host, String.valueOf(port), username);
throw new APPCException(message, e);
}
}
+ private void createConnection(NetconfConnectionDetails connectionDetails) throws APPCException {
+ try {
+// session.setServerAliveCountMax(0); // If this is not set to '0', then socket timeout on all reads will not work!!!!
+ channel = session.openChannel("subsystem");
+ ((ChannelSubsystem)channel).setSubsystem("netconf");
+ netconfAdapter = new NetconfAdapter(channel.getInputStream(), channel.getOutputStream());
+ channel.connect(CHANNEL_CONNECT_TIMEOUT);
+ hello(connectionDetails.getCapabilities());
+ } catch(Exception e) {
+ disconnect();
+ throw new APPCException(e);
+ }
+ }
+
private void hello(List<String> capabilities) throws IOException {
String helloIn = netconfAdapter.receiveMessage();
if(helloIn == null) {