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:
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.
You should create a configuration file for NATS. And push it to the container as a Docker volume and set the command
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