Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ably-go unnecessarily base64 encodes messages when sending over messagepack #583

Open
amnonbc opened this issue Jan 16, 2023 · 1 comment

Comments

@amnonbc
Copy link
Contributor

amnonbc commented Jan 16, 2023

See

case []byte:
m.Data = base64.StdEncoding.EncodeToString(d)
m.Encoding = mergeEncoding(m.Encoding, encBase64)

The spec states:

(RSL4c) When using MessagePack Message encoding
(RSL4c1) a binary Message payload is encoded as MessagePack binary type
(RSL4c2) a string Message payload is encoded as MessagePack string type
(RSL4c3) a JSON Message payload is stringified either as a JSON Object or Array and encoded as MessagePack string type and the encoding attribute is set to “json”
(RSL4c4) All messages received will deliver payloads in the format they were sent in i.e. binary, string, or a structured type containing the parsed JSON
(RSL4d) When using JSON Message encoding
(RSL4d1) a binary Message payload is encoded as Base64 and represented as a JSON string the encoding attribute is set to “base64”
(RSL4d2) a string Message payload is represented as a JSON string
(RSL4d3) a JSON Message payload is stringified either as a JSON Object or Array and represented as a JSON string and the encoding attribute is set to “json”
(RSL4d4) All messages received will be decoded based on the encoding field and deliver payloads in the format they were sent in i.e. binary, string, or a structured type containing the parsed JSON

So when we are using JSON message encoding we must Base64 encode binary message payloads (RSL4d1).
But when we are sending using MessagePack, we should send a binary payload as MessagePack binary type.

This bug does not prevent messages from being delivered. But the extra base64 encoding creates extra CPU load on the client.

┆Issue is synchronized with this Jira Task by Unito

@sync-by-unito
Copy link

sync-by-unito bot commented Jan 16, 2023

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3248

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant