Client { public void connect( String host, int port, String password, int timeoutSeconds ) throws InboundConnectionFailure { if ( canSend() ) { close(); } ClientBootstrap bootstrap = new ClientBootstrap( new NioClientSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool() ) ); InboundClientHandler handler = new InboundClientHandler( password, protocolListener ); bootstrap.setPipelineFactory( new InboundPipelineFactory( handler ) ); ChannelFuture future = bootstrap.connect( new InetSocketAddress( host, port ) ); if ( ! future.awaitUninterruptibly( timeoutSeconds, TimeUnit.SECONDS ) ) { throw new InboundConnectionFailure( "Timeout connecting to " + host + ":" + port ); } channel = future.getChannel(); if ( !future.isSuccess() ) { log.warn( "Failed to connect to [{}:{}]", host, port ); log.warn( " * reason: {}", future.getCause() ); channel = null; bootstrap.releaseExternalResources(); throw new InboundConnectionFailure( "Could not connect to " + host + ":" + port, future.getCause() ); } while ( ! authenticatorResponded.get() ) { try { Thread.sleep( 250 ); } catch ( InterruptedException e ) { } } if ( ! authenticated ) { throw new InboundConnectionFailure( "Authentication failed: " + authenticationResponse.getReplyText() ); } }  boolean canSend(); void addEventListener( IEslEventListener listener ); void connect( String host, int port, String password, int timeoutSeconds ); EslMessage sendSyncApiCommand( String command, String arg ); String sendAsyncApiCommand( String command, String arg ); EslMessage sendSyncApiCommand( String command, String arg, long timeout); String sendAsyncApiCommand( String command, String arg , long timeout); CommandResponse setEventSubscriptions( String format, String events ); CommandResponse cancelEventSubscriptions(); CommandResponse addEventFilter( String eventHeader, String valueToFilter ); CommandResponse deleteEventFilter( String eventHeader, String valueToFilter ); CommandResponse setLoggingLevel( String level ); CommandResponse cancelLogging(); CommandResponse close();  }
@Test public void do_multi_connects() throws InterruptedException { Client client = new Client(); log.info( "Client connecting .." ); try { client.connect( host, port, password, 2 ); } catch ( InboundConnectionFailure e ) { log.error( "Connect failed", e ); return; } log.info( "Client connected .." ); log.info( "Client connecting .." ); try { client.connect( "127.0.0.1", 8021, password, 2 ); } catch ( InboundConnectionFailure e ) { log.error( "Connect failed", e ); return; } log.info( "Client connected .." ); }