How does Ably measure message size?

The message size for limits and pricing is considered to be the sum of the sizes of all of the parts of a message that are under control of the client, including name, clientId, and data, before any compression (or expansion) that occurs in the serialization process. The size in bytes is calculated as the sum of the size in bytes of the utf8 representation of name and clientId, plus the size of the data (which is either its size, if it is binary, or its utf8 byte length if it is a string).


If the data is binary and the message is sent on a text transport and therefore has base64-encoded data in the data  attribute, and has an encoding  attribute of base64, the size limit applied is the actual size of the binary data, not the size of the base64-encoded string.