Java `LedgerClient` - what does `connect()` do exactly?

When using the Java Client Library, the documentation instructs us to build a DamlLedgerClient and then to execute the connect().

The documentation says that this method

Connects to the ledger and runs initial validation.

What is this initial validation? Do you need the auth token necessarily for this call? I was assuming that any auth verification would take place only when I am sending commands or subscribe to a stream.

This is probably a bit outdated, given that the ledger ID is now deprecated, but the validation mentioned in the Javadoc is to accept a ledger ID and verify it matches the one on the Ledger API. If no ledger ID is provided, the connect method will instantiate the LedgerIdentityClient, retrieve the ledger ID, store it for use with other services so that it doesn’t have to be issued with every call and instantiate a client for each service exposed via the Java bindings.

You don’t need a token to run this call if you’re not running against a secure Ledger API server. You can provide one as part of constructing the client and optionally do it on a call-by-call basis if you need to refresh it over time.