core-rs-albatross icon indicating copy to clipboard operation
core-rs-albatross copied to clipboard

JSON-RPC server returns frames as binary unlike most of the ecosystem

Open blouflashdb opened this issue 1 month ago • 17 comments

Most of the JSON-RPC ecosystem over WebSockets returns JSON over text frames, unlike the Nimiq JSON-RPC server. This creates friction for existing client libraries that expect the responses over text frames.

Original text Dear Nimiq Development Team,

I am reaching out with a question regarding the implementation of your JSON-RPC 2.0 API, specifically in the context of WebSocket transport.

According to the JSON-RPC 2.0 specification, messages are expected to be JSON-encoded text. However, it seems that your WebSocket implementation sends responses as binary data (e.g., serialized JSON), which deviates from the standard's expectation of JSON text messages.

This has caused issues when using the API in browser environments, where binary messages are received as Blob objects, requiring additional steps to decode them into JSON. While this is manageable with workarounds, it introduces challenges for strict JSON-RPC 2.0 clients and libraries, which are designed to expect text-based JSON responses.

Could you clarify why the WebSocket transport sends binary data instead of JSON text, and if there are any plans to align the implementation with the JSON-RPC 2.0 specification in the future?

Thank you for your time and for the work you’re doing on the Nimiq ecosystem!

Best regards Daniel Schmitz

blouflashdb avatar Jan 12 '25 20:01 blouflashdb