Skip to content

Commit 0aa095c

Browse files
SolarisYankevin-bates
authored andcommitted
Fix binary message issue when configured to forward to gateway (#4576)
If the message is bytes, we should set binary=True This is a port from NB2KG PR jupyter/nb2kg#33
1 parent dc68c76 commit 0aa095c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

jupyter_server/gateway/handlers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def on_message(self, message):
9292
def write_message(self, message, binary=False):
9393
"""Send message back to notebook client. This is called via callback from self.gateway._read_messages."""
9494
if self.ws_connection: # prevent WebSocketClosedError
95+
if isinstance(message, bytes):
96+
binary = True
9597
super(WebSocketChannelsHandler, self).write_message(message, binary=binary)
9698
elif self.log.isEnabledFor(logging.DEBUG):
9799
msg_summary = WebSocketChannelsHandler._get_message_summary(json_decode(utf8(message)))

0 commit comments

Comments
 (0)