I am trying to use websockets in binary mode to transfer binary data from a server written in Python to a client browser (running javascript). I have implemented this communication in text mode, but now I wish to boost the performance by communicating in binary mode instead.
All the examples I have seen (eg this, and also if one dig through the source code of matplotlib/webagg which uses Tornado) claim they are using binary mode, but in fact they seem to encode the raw binary data into UTF-8 (or base64) at some point before transmission. In my view doing this is not true binary transfer as it adds 30% to 50% overhead.
So my question is, do one necessarily have to encode the binary data into utf-8 or base64 in order to use IP based websockets? If not, please point me to an example where this is done without encoding.
I have always believed that sockets do support true binary communication but maybe this is not the case for IP websockets for some reason. Perhaps someone can shed light onto the matter. There seem to have been advances in the past year or so in this area so that adds to the confusion.