Problem starting JSON API on all interfaces

daml start --json-api-option "--address 0.0.0.0" gives me

Waiting for JSON API to start:
Error: Unknown option --address 0.0.0.0

What am I doing wrong?

2 Likes

If you pass --json-api-option myoption (and the same holds for --sandbox-option and --navigator-option), the JSON API will see exactly one argument with the value myoption. There is no magic splitting on spaces performed here. So for your example the JSON API sees a single argument of value --address 0.0.0.0. However, it expects this to be passed as two arguments instead: First --address and then 0.0.0.0. There are two ways to fix this:

  1. Change the syntax so that JSON-API accepts it as a single option. Pretty much all tools allow you to use an = sign to separate the option name and the value and pass them in a single argument. So for your example that would be --json-api-option "--address=0.0.0.0".
  2. Use --json-api-option multiple times: So for your example that would be --json-api-option "--address" --json-api-option "0.0.0.0.

For this simple example I would probably go with 1 but in general if you actually have multiple completely separate options you have to use option 2 to separate them.

1 Like

Is your option 2 something that should work or does it require code change on your end? I’ve tried this on SDK 1.14.0:

daml start --json-api-option --ledger-host --json-api-option myhost --json-api-option --ledger-port --json-api-option XXXX

But I get:

.Waiting for JSON API to start:
Error: Unknown option --ledger-host
Error: Unknown argument 'myhost'
Error: Unknown option --ledger-port
Error: Unknown argument 'XXXX'
Try --help for more information.
1 Like

I think you can’t set the ledger host and port for the JSON API independently when using daml start. daml start automatically passes localhost and the sandbox port to the JSON API via CLI flags so setting your own CLI flags causes a clash resulting in a somewhat misleading error message.

If you want to start the json-api against a remote ledger, use daml json-api. If you want to run the sandbox and JSON API with a non-standard Ledger API port using daml start, use daml start --sandbox-port XXXX.

2 Likes