How to run `daml start` with several specific parameters

G-d willing

Hello,
when I am running the JSON-API I am using the following command:

daml json-api --ledger-host localhost --ledger-port 6865 --http-port 7575 --max-inbound-message-size=9000000

How can I ensure this will be set when I run daml start?
I want to control these arguments in daml start in case I need to change them.

Thanks

You can place json-api-options in your daml.yaml file. See here.

For example:

json-api-options: 
  - --log-level=DEBUG
  - --max-inbound-message-size=9000000

The “ledger host” for daml start is localhost. I’m not sure that can be changed with daml start.

For the ports, daml start has these two command line options:

  • --sandbox-port 6865
  • --json-api-port 7575
2 Likes

Hi @WallaceKelly,
Thank you for your reply. I added the json-api-options to the daml.yaml file, and also added the arguments you mentioned to it. But when I ran daml start I received the following error:

Error: Unknown option --sandbox-port=6865
Error: Unknown option --json-api-port=7575

And when I used:

json-api-options:
  - --ledger-port=6865
  - --http-port=7575
  - --max-inbound-message-size=9000000

then I received:

Waiting for canton sandbox to start.
Exception in thread "main" java.io.IOException: Failed to bind to address /127.0.0.1:6866

Not sure where this 6866 is coming from

@cohen.avraham, the json-api-options of the daml.yaml file contains options which the Daml Assistant (daml start) will pass to the HTTP JSON API binary (http-json-binary). You can see what those options can be by placing --help in that section like this:

json-api-options:
   - --help

When you run daml start with --help in the json-api-options as above it will not complete, but show you the command line options for the Sandbox’s HTTP JSON API service. You will not see sandbox-port or json-api-port in that list. Consequently, if you try to include those two options in the json-api-options section of the daml.yaml file, you get “Error: Unknown option.”

The two options sandbox-port and json-api-port are command line options for daml start. The following will work:

daml start --sandbox-port 6865 --json-api-port 7575

See this related post, which explains that because the daml assistant has an --json-api-port option, you cannot put --http-port in the json-api-options section of the daml.yaml file. :face_with_diagonal_mouth:

Hi @WallaceKelly ,
I tried what you suggested, but it is not working.

I tried the following command:

daml start --sandbox-port 6865 --json-api-port 7575

And the following error was received:

Frontend running at http://localhost:7500.
.Waiting for JSON API to start: 
Error: Unknown option --ledger-port=6865
Error: Unknown option --http-port=7575
Try --help for more information.

In addition, I tried running the command again, and I am getting a different error:

Waiting for canton sandbox to start.
Exception in thread "main" java.io.IOException: Failed to bind to address /127.0.0.1:6868
        at io.grpc.netty.NettyServer.start(NettyServer.java:333)
        at io.grpc.internal.ServerImpl.start(ServerImpl.java:185)
        at io.grpc.internal.ServerImpl.start(ServerImpl.java:94)
        at com.digitalasset.canton.environment.CantonNodeBootstrapCommon.<init>(CantonNodeBootstrapCommon.scala:197)
        at com.digitalasset.canton.environment.CantonNodeBootstrapBase.<init>(CantonNodeBootstrap.scala:64)
        at com.digitalasset.canton.domain.DomainNodeBootstrap.<init>(DomainNodeBootstrap.scala:113)
        at com.digitalasset.canton.domain.EnterpriseDomainFactory$.$anonfun$create$1(EnterpriseDomainFactory.scala:35)
        at scala.util.Either.map(Either.scala:382)
        at com.digitalasset.canton.domain.EnterpriseDomainFactory$.create(EnterpriseDomainFactory.scala:34)
        at com.digitalasset.canton.environment.Environment.createDomain(Environment.scala:552)
        at com.digitalasset.canton.environment.Environment.createDomain$(Environment.scala:547)
        at com.digitalasset.canton.environment.EnterpriseEnvironment.createDomain(EnterpriseEnvironment.scala:63)
        at com.digitalasset.canton.environment.Environment.$anonfun$domains$1(Environment.scala:271)
        at com.digitalasset.canton.environment.ManagedNodes.$anonfun$startNode$2(Nodes.scala:158)
        at cats.data.EitherT.$anonfun$bimap$1(EitherT.scala:423)
        at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:467)
        at com.daml.executors.QueueAwareExecutorService$TrackingRunnable.run(QueueAwareExecutorService.scala:98)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: java.net.BindException: Address already in use: bind
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:556)
        at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:344)
        at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:301)
        at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:141)
        at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334)
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:600)
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:579)
        at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973)
        at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260)
        at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:380)
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:1623)
Port file was not written to 'C:\Users\Acohen\AppData\Local\Temp\extra-dir-406583509887\sandbox-portfile' in time.
Error: Unknown option --ledger-port=6865
Error: Unknown option --http-port=7575

My guess is that the above errors are coming from your daml.yaml file in the json-api-options section. If so, you should remove those two options from there.

Failed to bind to address /127.0.0.1:6868

I don’t know where the port 6868 is coming from. Maybe search your directory for “6868”?

You are right, I forgot removing them from the daml.yaml file.
But, the second error about port 6868 is still there. I have no idea where it is coming from. And I don’t have any folder with such name.

@cohen.avraham Ports 6865 - 6869 are the default ports used by various Daml sandbox processes. I think the error you see is likely due to port 6868 being occupied (probably by a runaway process from your previous tests that didn’t terminate correctly) when you start Daml sandbox. I suggest you check if there’s any process running that occupies port 6868 and kill it. Rebooting the machine is obviously another option.

1 Like