diff --git a/notebook/gateway/handlers.py b/notebook/gateway/handlers.py index 0fbbfb18b9..06d6cc8fef 100644 --- a/notebook/gateway/handlers.py +++ b/notebook/gateway/handlers.py @@ -80,6 +80,8 @@ def write_message(self, message, binary=False): """Send message back to notebook client. This is called via callback from self.gateway._read_messages.""" self.log.debug("Receiving message from gateway: {}".format(message)) if self.ws_connection: # prevent WebSocketClosedError + if isinstance(message, bytes): + binary = True super(WebSocketChannelsHandler, self).write_message(message, binary=binary) elif self.log.isEnabledFor(logging.DEBUG): msg_summary = WebSocketChannelsHandler._get_message_summary(json_decode(utf8(message)))