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

pull/12/merge
Sheng 7 years ago
parent 28360c31e2
commit 191bb109e0

@ -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')

Loading…
Cancel
Save