@Override public void connect() { try { log.debug("Starting connection to telnet device"); if (loggedIn) { throw new IllegalStateException("Already connected"); } log.info(String.format("Connecting to telnet service at %s:%d", targetHost, targetPort)); client.setConnectTimeout(targetTimeout); client.connect(targetHost, targetPort); expector = new Expect(client.getInputStream(), client.getOutputStream(), executorService, log); expector.setDefaultTimeout(targetTimeout); expector.setThrowOnError(true); loggedIn = true; } catch (Exception e) { throw new InteractiveSpacesException( String.format( "Error while connecting to telnet service at %s:%d", targetHost, targetPort), e); } }