Binary vs text websocket frames

Visto 53 veces
Saltar al primer mensaje no leído

Christian Schafmeister

no leída,
18 dic 2017, 9:23:1618/12/17
a Project Jupyter
Hello,

How can I control whether the jupyter server sends binary websocket frames vs text websocket frames to the browser?

When monitoring websocket traffic between an ipython jupyter notebook kernel and the browser, all websocket frames, both to the browser and from the browser are in websocket text frames.  This makes it easy to read the JSON dictionaries using almost any browser.
When monitoring websocket traffic between our Common Lisp kernel and a browser, the websocket frames to the browser are binary websocket frames and the frames from the browser are websocket text frames. 
I recently learned that it is the jupyter notebook server (written in python) that is interposed between our kernel and the browser that is carrying out this websocket communication.  Why is it using binary frames?  Binary websocket frames are a lot harder to dig into and extract the JSON from.

I'd like to monitor the websocket traffic between the jupyter server and the browser for debugging.
It has been extremely helpful to do this in a painful/limited way to add jupyter widgets support to our kernel (based on cl-jupyter/Common Lisp).

Best,

Christian Schafmeister
Professor
Chemistry Department
Temple University

Jason Grout

no leída,
18 dic 2017, 13:17:3518/12/17
a jup...@googlegroups.com
The websocket frames are sent in either binary or text, depending on whether there are binary buffers encoded in the message (it is a per-message decision, not an overall decision). The decision logic is here: https://github.com/jupyter/notebook/blob/ca50f1af5afb525fd95b98b2e61e69db28094467/notebook/base/zmqhandlers.py#L230

I think it would be very useful to have either something that can log the messages in the kernel, right around that logic. Another interesting change would be to have a debug switch in the notebook server that encodes any binary message buffers with base64 so the websocket message can still be a text websocket frame. Another place to put the logging logic is in the frontend, after the message has been converted back into a native js object.

Jason


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/9915a01a-5704-4671-86ce-5c33793504ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Christian Schafmeister

no leída,
19 dic 2017, 7:29:5919/12/17
a Project Jupyter
Thank you very much!
Our messages appear to always add a "buffers" field even when the list of buffers is empty.  I'll fix that.
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos