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

**URL:** <https://forum.canton.network/t/java-ledgerclient-what-does-connect-do-exactly/4535>\
**Category:** App Development\
**Tags:** java, ledger-api\
**Created:** [May 16, 2022, 1:54pm UTC](https://forum.canton.network/t/java-ledgerclient-what-does-connect-do-exactly/4535 "2022-05-16T13:54:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darko](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/darko/32/42_2.png) [@Darko](https://forum.canton.network/u/Darko)\
**Post date:** [May 16, 2022, 1:54pm UTC](https://forum.canton.network/t/java-ledgerclient-what-does-connect-do-exactly/4535/1 "2022-05-16T13:54:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [May 16, 2022, 2:03pm UTC](https://forum.canton.network/t/java-ledgerclient-what-does-connect-do-exactly/4535/2 "2022-05-16T14:03:31Z")

</div>

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.
