admin管理员组

文章数量:1410737

My problem is that I need to increase max_payload value that NATS receive but I have no idea where I can do it.

The project is using Moleculer and NATS is created as a container with docker.


When I try to make a request which is bigger than 1MB NATS returns:

ERROR - NATS error. 'Maximum Payload Violation

Inside dockstation logs NATS returns:

cid:1 - maximum payload exceeded: 1341972 vs 1048576

I tried the following items:

  • Changing tranporter inside Moleculer Broker configs (/docs/0.12/transporters.html);
  • Add an config file for NATS to modify some options ();

Code example of Moleculer Broker configs:

const brokerConfig: BrokerOptions = {
  ...,
  transporter: "NATS",
  transit: {
    maxQueueSize: 100000,
    disableReconnect: false,
    disableVersionCheck: false,
  },
  ...
}

Code example of nats config file:

{
  max_payload: 1000000
}

Error when I run docker with NATS config file:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/home/matheus/nats-server.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/08959b2fce0deb2abea27e103f7f4426b7ed6f3ef64b214f713ebb993c2373e6/merged\\\" at \\\"/var/lib/docker/overlay2/08959b2fce0deb2abea27e103f7f4426b7ed6f3ef64b214f713ebb993c2373e6/merged/nats-server.conf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type. error Command failed with exit code 125.

My problem is that I need to increase max_payload value that NATS receive but I have no idea where I can do it.

The project is using Moleculer and NATS is created as a container with docker.


When I try to make a request which is bigger than 1MB NATS returns:

ERROR - NATS error. 'Maximum Payload Violation

Inside dockstation logs NATS returns:

cid:1 - maximum payload exceeded: 1341972 vs 1048576

I tried the following items:

  • Changing tranporter inside Moleculer Broker configs (https://moleculer.services/docs/0.12/transporters.html);
  • Add an config file for NATS to modify some options (https://hub.docker./_/nats);

Code example of Moleculer Broker configs:

const brokerConfig: BrokerOptions = {
  ...,
  transporter: "NATS",
  transit: {
    maxQueueSize: 100000,
    disableReconnect: false,
    disableVersionCheck: false,
  },
  ...
}

Code example of nats config file:

{
  max_payload: 1000000
}

Error when I run docker with NATS config file:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/home/matheus/nats-server.conf\\\" to rootfs \\\"/var/lib/docker/overlay2/08959b2fce0deb2abea27e103f7f4426b7ed6f3ef64b214f713ebb993c2373e6/merged\\\" at \\\"/var/lib/docker/overlay2/08959b2fce0deb2abea27e103f7f4426b7ed6f3ef64b214f713ebb993c2373e6/merged/nats-server.conf\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type. error Command failed with exit code 125.
Share Improve this question edited Jan 9, 2021 at 18:38 Matheus Chignolli asked Jan 9, 2021 at 2:00 Matheus ChignolliMatheus Chignolli 351 silver badge7 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 8

You should create a configuration file for NATS. And push it to the container as a Docker volume and set the mand as -c nats-server.conf

nats-server.conf

max_payload: 4Mb

Start container

docker run -d -p 4222:4222 -v ~/nats-server.conf:/nats-server.conf nats -c /nats-server.conf

本文标签: javascriptNATS with moleculer How can I change NATS maxpayload valueStack Overflow