Particle.publish() max length is 256 not 622

Hi, I’m using the Argon to publish a message, however, I’m running into the problem that the max data message size is 256 characters and not the 622 as mentioned in the documentation.

Is this a known issue?

What device OS version are you running?

2.0.0 rc3 but i had the same issue with 1.5.2

Nope, I cannot confirm that.
With this test code (on 2.0.0-rc.3) I can clearly see that 622 bytes get transferred.

void setup() {
  Particle.function("test", test);
  Particle.subscribe("test", pubLen);

int test(const char* command) {
  char msg[623];
  for (int i = 0; i < sizeof(msg)-1; i++)
    msg[i] = (i % 74) + 0x31;
  msg[sizeof(msg)-1] = '\0';
  Particle.publish("test", msg); 
  return strlen(msg);

void pubLen(const char* event, const char* data) {
  char msg[16];
  snprintf(msg, sizeof(msg), "%d", strlen(data));
  Particle.publish("len", msg);

What kind of data are you trying to send?
Can you provide a sample code that exhibits the issue?

1 Like


Here you see I receive exactly 265 characters:

I’m using a JSON writer as follows:

JsonWriterStatic<256> writer;
JsonWriterAutoObject obj(&writer);


Particle.publish("IAQ", writer.getBuffer(), PRIVATE);

Where values 0 to x would be readings from my sensors.

That’s sooo dumb… I see already. My json writer is only 256 long