Native extension exceed message limit

Hi, everyone
I’m working on a firefox extension that has a native part. But I keep getting the same error: “Native application tried to send a message of 1684611707 bytes, which exceeds the limit of 1048576 bytes.”

The native part is a C program and right now I only use to send a small json string. I’ve googled this for a long time without luck. So anyone knows what can be the cause of this kind of error??

Thanks a lot!

This sounds like an encoding issue with the message, if the string is below the number of bytes Firefox seems to think are in the message.

I try to send message like this
fprintf(stdout, “{\“id\”: 23453}”)
which is a valid json string, right??
Oh, and I’m on Windows7, is there anything about the encoding I should care on windows platform?

As https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging outlines, the first 32 bits of your message must be a unit with the length of the string you are sending in bytes (same as the incoming message format).