##// END OF EJS Templates
protect websocket against errant messages...
Min RK -
Show More
@@ -214,6 +214,10 b' class ZMQChannelsHandler(AuthenticatedZMQStreamHandler):'
214 stream.on_recv_stream(self._on_zmq_reply)
214 stream.on_recv_stream(self._on_zmq_reply)
215
215
216 def on_message(self, msg):
216 def on_message(self, msg):
217 if not self.channels:
218 # already closed, ignore the message
219 self.log.debug("Received message on closed websocket %r", msg)
220 return
217 if isinstance(msg, bytes):
221 if isinstance(msg, bytes):
218 msg = deserialize_binary_message(msg)
222 msg = deserialize_binary_message(msg)
219 else:
223 else:
@@ -222,6 +226,9 b' class ZMQChannelsHandler(AuthenticatedZMQStreamHandler):'
222 if channel is None:
226 if channel is None:
223 self.log.warn("No channel specified, assuming shell: %s", msg)
227 self.log.warn("No channel specified, assuming shell: %s", msg)
224 channel = 'shell'
228 channel = 'shell'
229 if channel not in self.channels:
230 self.log.warn("No such channel: %r", channel)
231 return
225 stream = self.channels[channel]
232 stream = self.channels[channel]
226 self.session.send(stream, msg)
233 self.session.send(stream, msg)
227
234
General Comments 0
You need to be logged in to leave comments. Login now