Warning

This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: html.base.zmqhandlers

Tornado handlers for WebSocket <-> ZMQ sockets.

2 Classes

class IPython.html.base.zmqhandlers.ZMQStreamHandler(application, request, **kwargs)

Bases: tornado.websocket.WebSocketHandler

check_origin(origin)

Check Origin == Host or Access-Control-Allow-Origin.

Tornado >= 4 calls this method automatically, raising 403 if it returns False.

meaningless for websockets

class IPython.html.base.zmqhandlers.AuthenticatedZMQStreamHandler(application, request, **kwargs)

Bases: IPython.html.base.zmqhandlers.ZMQStreamHandler, IPython.html.base.handlers.IPythonHandler

ping_interval

The interval for websocket keep-alive pings.

Set ws_ping_interval = 0 to disable pings.

ping_timeout

If no ping is received in this many milliseconds, close the websocket connection (VPNs, etc. can fail to cleanly close ws connections). Default is max of 3 pings or 30 seconds.

pre_get()

Run before finishing the GET request

Extend this method to add logic that should fire before the websocket finishes completing.

send_ping()

send a ping to keep the websocket alive

set_default_headers()

Undo the set_default_headers in IPythonHandler

which doesn’t make sense for websockets

2 Functions

IPython.html.base.zmqhandlers.serialize_binary_message(msg)

serialize a message as a binary blob

Header:

4 bytes: number of msg parts (nbufs) as 32b int 4 * nbufs bytes: offset for each buffer as integer as 32b int

Offsets are from the start of the buffer, including the header.

Returns:The message serialized to bytes.
IPython.html.base.zmqhandlers.deserialize_binary_message(bmsg)

deserialize a message from a binary blog

Header:

4 bytes: number of msg parts (nbufs) as 32b int 4 * nbufs bytes: offset for each buffer as integer as 32b int

Offsets are from the start of the buffer, including the header.

Returns:message dictionary