Skip to content

Commit

Permalink
Fix binary message issue when configured to forward to gateway (#4576)
Browse files Browse the repository at this point in the history
If the message is bytes, we should set binary=True
This is a port from NB2KG PR jupyter/nb2kg#33
  • Loading branch information
SolarisYan authored and lresende committed Jun 25, 2019
1 parent 8d98489 commit 83f591b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions notebook/gateway/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit 83f591b

Please sign in to comment.