try to handle overflowing connections
This commit is contained in:
parent
4b2100b593
commit
e8a1a40dc0
@ -38,12 +38,16 @@ class WebSocketConnection(object):
|
|||||||
# string-type messages are sent as text frames
|
# string-type messages are sent as text frames
|
||||||
if (type(data) == str):
|
if (type(data) == str):
|
||||||
header = self.get_header(len(data), 1)
|
header = self.get_header(len(data), 1)
|
||||||
self.handler.wfile.write(header + data.encode('utf-8'))
|
data_to_send = header + data.encode('utf-8')
|
||||||
self.handler.wfile.flush()
|
|
||||||
# anything else as binary
|
# anything else as binary
|
||||||
else:
|
else:
|
||||||
header = self.get_header(len(data), 2)
|
header = self.get_header(len(data), 2)
|
||||||
self.handler.wfile.write(header + data)
|
data_to_send = header + data
|
||||||
|
written = self.handler.wfile.write(data_to_send)
|
||||||
|
if (written != len(data_to_send)):
|
||||||
|
logger.error("incomplete write! closing socket!")
|
||||||
|
self.close()
|
||||||
|
else:
|
||||||
self.handler.wfile.flush()
|
self.handler.wfile.flush()
|
||||||
|
|
||||||
def read_loop(self):
|
def read_loop(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user