Running multiple instances of create-daml-app simultaneously against multiple participants

Is there a way to run multiple instances of the create-daml-app UI at once, with the different UI instances connected to different instances of the http json api?

As far as I can see, create-daml-app relies on the http json api running on port 7575, so it looks like this can’t be done, but perhaps I missed something. If this actually can’t be done, would anyone mind me having a try at adding it?

2 Likes

The URLs and ports are configured in daml/config.ts at bda565fa4470d77a803fb4d9f0f6de41e4bf282a · digital-asset/daml · GitHub. This probably needs to be made a tad more flexible to allow the passing in of URLs and ports via environment variables. The app is intended to be cloned and modified so I’m not sure the functionality should be built in. I’d rather suggest you make the modification yourself. E.g. a simple measure would be to change line 34 from

  ? 'ws://localhost:7575/'

to

  ?  process.env.WS_BASE_URL || 'ws://localhost:7575/'

Then you can run

WS_BASE_URL=wss://my.legher.io:1234/; yarn start
3 Likes

It looks to me like the port is also configured from the package.json, in this line: ui/package.json.template: "proxy": "http://localhost:7575", although I don’t know whether this is needed right now. If it is needed, then the change may not be as simple as a 1-liner. I don’t think you can read from environment variables in your package.json.

I am not keen to clone and modify the app, and would prefer to modify create-daml-app itself. I am writing a “run create-daml-app on Canton” tutorial and I think it would be a bad experience if the users can’t just run the original create-daml-app.

Thoughts on whether this is a good-enough reason to add the functionality to create-daml-app? Happy to do it myself ofc

1 Like

The webpack proxy configured in package.json only supports a single URL afaik. If you instead specify different hosts/ports directly when creating your DamlLedger context, you’ll likely run into CORS issues. So the only option I see is for you to run multiple instances of the create-daml-app project.

1 Like

You could configure that via a .js configuration rather than through package.json, I think. You just create a webpack.config.js file in your project root and configure according to https://webpack.js.org/configuration/dev-server/

2 Likes

I have now added this feature to create-daml-app, here’s the PR if you’re interested.

From the next release, it will be possible to specify the JSON API port expected by create-daml-app via the environment variable REACT_APP_HTTP_JSON_PORT when running in dev mode (ie a local yarn start).

4 Likes

Any suggestion how can start the ledger for multiple parties? @Phoebe_Nichols I need to understand is that possible to run create-daml-app for multiple parties on daml sandbox , if yes , then how?

1 Like

@vsh1982 you don’t need to do anything special for starting Sandbox. Just starting it via daml start or daml sandbox will do the trick. And you only need one instance of create-daml-app if you’re running with Sandbox. The getting started guide shows you how to set things up for two parties Alice and Bob but you can use arbitrary other parties without changes.

This thread is about distributed ledgers like Canton where different parties might be hosted on different participants. In that case you need one instance of create-daml-app per participant. But as long as you’re working with Sandbox there is no need to worry about any of that.

1 Like

@cocreature Thank you for your response . I am looking from distributed ledger perspective only . As per my understanding , every party have it’s node and the node have it’s Vault . I am not able to find the nodes and nodes information while using the application locally . Where I can find this ? My requirement is to use this application in DAML network and all parties can configured with different UI and server code .

1 Like

If you run with Sandbox, there is only one node so you won’t find anything else. If you want a distributed setup, take a look at how to run create-daml-app with Canton for example DAML SDK and Canton — Canton 0.25.0 documentation

1 Like

got it , Thanks alot !!

1 Like