void connect ( boolean reconnectOnConnect ) throws InterruptedException , IOException { if ( options . getServers ( ) . size ( ) == 0 ) { throw new IllegalArgumentException ( "No servers provided in options" ) ; } for ( String serverURI : getServers ( ) ) { if ( isClosed ( ) ) { break ; } updateStatus ( Status . CONNECTING ) ; tryToConnect ( serverURI ) ; if ( isConnected ( ) ) { break ; } else { updateStatus ( Status . DISCONNECTED ) ; } } if ( ! isConnected ( ) && ! isClosed ( ) ) { if ( reconnectOnConnect ) { reconnect ( ) ; } else { close ( ) ; throw new IOException ( "Unable to connect to gnatsd server." ) ; } } }
Connect is only called after creation