Commit 191bb109 by Sheng

Fixed a bug that client closes websocket on handling non utf-8 encoded bytes

parent 28360c31
......@@ -91,8 +91,14 @@ jQuery(function($){
};
socket.onmessage = function(msg) {
// console.log(msg);
term.write(msg.data);
var reader = new FileReader();
reader.onloadend = function(event){
var decoder = new TextDecoder();
var text = decoder.decode(reader.result);
// console.log(text);
term.write(text);
};
reader.readAsArrayBuffer(msg.data);
};
socket.onerror = function(e) {
......
......@@ -63,7 +63,7 @@ class Worker(object):
logging.debug('{!r} to {}:{}'.format(data, *self.handler.src_addr))
try:
self.handler.write_message(data)
self.handler.write_message(data, binary=True)
except tornado.websocket.WebSocketClosedError:
self.close(reason='websocket closed')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment