Running ddit integration outside of daml hub

Hello all,

I’m working on project where my team have built an integration built in python using the ddit package with the intention of being deployed in daml hub. However it is not possible at the time to have the integration running there, due to external factors. As such we’re experimenting in running the integration external to daml hub, but we are getting a connection issue:

today at 09:36:312022-07-26T08:36:31+0000 [INFO] (dazl) Establishing a connection to https://foobar.daml.app:443 on party ledger-party-abc...
today at 09:38:312022-07-26T08:38:31+0000 [INFO] (dazl) Closing a GRPCv1Connection channel...
today at 09:38:312022-07-26T08:38:31+0000 [ERROR] (daml-dit-if) The main dazl coroutine died with an exception
today at 09:38:31Traceback (most recent call last):
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/daml_dit_if/main/main.py", line 65, in run_dazl_network
today at 09:38:31    await network.aio_run()
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/dazl/client/api.py", line 404, in aio_run
today at 09:38:31    await self._impl.aio_run(*coroutines)
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/dazl/client/_network_client_impl.py", line 198, in aio_run
today at 09:38:31    await runner.run()
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/dazl/client/_network_client_impl.py", line 485, in run
today at 09:38:31    await self._init(
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/dazl/client/_network_client_impl.py", line 564, in _init
today at 09:38:31    await gather(*(party_impl.connect_in(self.pool) for party_impl in party_impls))
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/dazl/protocols/autodetect.py", line 69, in connect
today at 09:38:31    ledger = await self.ledger()
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/dazl/protocols/autodetect.py", line 45, in ledger
today at 09:38:31    return await self._ledger_future
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/dazl/protocols/autodetect.py", line 182, in _main
today at 09:38:31    for i, metadata in enumerate(_monitor_ledger_network(conn)):
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/dazl/protocols/autodetect.py", line 219, in _monitor_ledger_network
today at 09:38:31    ledger_id = grpc_detect_ledger_id(connection)
today at 09:38:31  File "/home/daml/foobar-integration/.ddit-venv/lib/python3.8/site-packages/dazl/protocols/v1/grpc.py", line 249, in grpc_detect_ledger_id
today at 09:38:31    raise ConnectionTimeoutError(
today at 09:38:31dazl.protocols.errors.ConnectionTimeoutError: connection timeout exceeded: 120.0 seconds
today at 09:38:312022-07-26T08:38:31+0000 [ERROR] (daml-dit-if) === FATAL ERROR: Execution cannot continue without dazl coroutine. ===

On looking for similar questions here on discuss, what we found was only using Dazl directly, where is is possible to manage tokens, and to my understanding this isn’t possible using the daml-dit-if.
Is it possible make such an integration run externally to daml hub?

2 Likes

Hi @David_Martins,

We just released a new version of daml-dit-if (0.6.7) which should allow you to use a Daml Hub JWT token to access the ledger.

You’ll need to add the following line to the requirements.txt for your integration:

dazl[oauth]

Next run ddit clean, then ddit install.

Following those steps, you should be able to specify the auth token with the DAML_LEDGER_TOKEN environment variable like as follows (sans brackets):

DABL_LEDGER_URL=https://{ledger_id}.daml.app DAML_LEDGER_TOKEN={jwt_token} ddit run {integration_type_id} --party {ledger_party}

Let me know if this works for you.

1 Like

Hello @alex.graham,

I’ve have tried the solution you’ve suggested, and i can confirm that connection is indeed possible with these steps.
Thank you.