0

I am new NATS. I just tried to send and receive a text file using NATS-streaming-server examples.

When I send a text file(~9B), it works


-Pub onnecting to cluster 'test-cluster' as client 'cs-publisher'. Publishing 1 messages on subject foo Url: nats://localhost:4222 Payload is 9 bytes. Published 1 msgs with acknowldegements in 0.0076917 seconds (130 msgs/second).

-Sub Connecting to cluster 'test-cluster' as client 'cs-subscriber'. Receiving 1 messages on subject foo url: nats://localhost:4222 received 1 msgs in 6E-07 seconds (1666666 msgs/second).


But, when I send a text file(~80MB), the subscribe didn't work.


-Pub Connecting to cluster 'test-cluster' as client 'cs-publisher'. Publishing 1 messages on subject foo Url: nats://localhost:4222 Payload is 77552640 bytes. Published 1 msgs with acknowldegements in 1.2574163 seconds (0 msgs/second).

-Sub Connecting to cluster 'test-cluster' as client 'cs-subscriber'. Receiving 1 messages on subject foo url: nats://loaclhost:4222


I don't know why subscribe doesn't react. I used same code and just changed the file what I sent.

byte[] payload = File.ReadAllBytes("test.txt");

....

string guid = c.Publish(subject, payload, (obj, pubArgs) =>

Please help me

de dedede
  • 1
  • 2

1 Answers1

0

the problem is NATS just supports message of sizes up to 1 MB. https://nats-io.github.io/docs/faq.html#is-there-a-message-size-limitation-in-nats

You have 2 solutions to the problem:

  1. Use an object store to store large data there and transmit the reference in the message.
  2. break up your message into multiple messages. Although I would be very careful here as you do not have guaranteed ordereing and the messages may end up (if they end up) on different subscribers. So this would highly question the use of NATS at all.
marcomeyer
  • 178
  • 7