Maximum data size per message via Socket API


I’m trying to send quite a large data (more than 10kB) in one JSON message via TCP Socket Embedded API at the moment. I have no problem to send a normal small sized JSON message through the socket using MKR GSM 1400.

The data is image data in base64 string, as the binary data not supported in JSON. I’d succeed to send the data in certain image size. But as the image size getting bigger, I kept getting error response from my debug output. At first I thought that the culprit was the SW-side of the MKR GSM library. So to proof it, I used the netcat console to send data with different size through the socket. With payload message with 10kB size, the sending was successful. But at 12kB, I got the response code [2,0], means couldn’t parsed the message. It is perhaps due to the limitation of JSON parser on the server.

So the question is, did anyone know the maximum data size that can be send in one message via Socket API?

I know it is possible to just send the image data by multiple packets, but if I knew the maximum allowed data size that can be handled by the parser, it will be an advantage on saving the data usage.

My understanding is the limit for a message you describe is 10,000 characters. However, you cannot arbitrarily scale that large post at some point. It should broken into much smaller chunks in a loop and reassembled at the destination. This way it will not matter what size file is transferring. Long transmissions can be a problem as the newtwork is slightly hostile to large data attachments. Me personally, I would probably work with 2,000 or so per transmission. Base64 is correct for binary but will not change the dynamics of a large file post. dy3

My testing also shows 10k (10,210 bytes to be exact) is the largest data payload I can send to the socket API. I agree Hologram should document this as its relatively small.

@dy3 can you expand on why you would chunk data like this at the application layer? My understanding is TCP does this for you (splits data into smaller packets for transmission and re-assembles at receiving end). 10kB is still pretty damn small even for 2G networks. I’m interested to learn if you have some experience with data of this size being an issue for cell networks.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.