Search code examples
autobahn

does AutobahnJS support binary messages?


When I send a binary message from a Python server to a JavaScript client, an exception is thrown from JSON.parse at this codeline. I'm sending the message like this:

server.sendMessageHybi(myBinaryChunk, binary=True)

On the receiving end, the data field is holding a Blob object rather than a string. Wondering if this is a supported workflow, or if I'm doing something wrong.


Solution

  • You can send binary WebSocket messages from AutobahnPython and receive those on browser-side with pure WebSocket (you don't need AutobahnJS for that).

    AutobahnJS is a WAMP implementation: RPC and PubSub over WebSocket. WAMPv1 uses text (JSON) messages for serialization and does not support (unencoded) binary payloads.

    There are considerations for supporting binary payloads in WAMPv2 (https://github.com/tavendo/wamp/issues/4)