I am trying to send a file using the nats messaging service. The size of the files may vary. Is there a way to send more than 1MB of data in a message body, or possible break and join the message body?
-
1Or you could upload it to some shared storage and only send a key to it. – zerkms Mar 27 '19 at 01:48
2 Answers
UPDATE 2022-09-19
According to the docs (https://docs.nats.io/reference/faq#is-there-a-message-size-limitation-in-nats) default size is 1M and can be increased up to 64M. (also see the other answer)
OUTDATED INFO
According to NATS FAQ you cannot send a message which size exceeds 1M (https://docs.nats.io/reference/faq#is-there-a-message-size-limitation-in-nats):
NATS does have a message size limitation that is enforced by the server and communicated to the client during connection setup. Currently, the limit is 1MB.
Messaging systems are not supposed to be used for file transfer. Use a distributed storage service to hold files and pass file ID in the message.

- 9,851
- 1
- 35
- 39
-
3
-
I'm using the same technique as you described, but there are problems when a file is processed by multiple services. Example service1 download file, process, upload processed file to storage. service 2 download file process by service 1, process, upload file to storage. This way we have so many bottleneck just to download and upload a file. Do you have any suggestion? Thanks. – Norak Mar 03 '22 at 09:00
-
The link is broken now. The following link looks as actual: https://docs.nats.io/reference/faq#is-there-a-message-size-limitation-in-nats – Bogdan Sep 19 '22 at 12:13
You can start Nats with a configuration file to define messages max size:
$ nats-server --config /path/to/nats.config
Configuration file example:
# Override message size limit (bytes):
max_payload: 100000000
See available options at https://docs.nats.io/nats-server/configuration#configuration-properties

- 18,610
- 7
- 91
- 99