Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 80070fa

Browse files
committed
Fixed bug with WebSocket/FlashSocket transport initialization, in case of
malformed/unsupported WebSocket handshake.
1 parent c69bd11 commit 80070fa

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tornadio/persistent.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def __init__(self, router, session_id):
2222
logging.debug('Initializing WebSocket handler...')
2323

2424
self.router = router
25+
self.connection = None
2526

2627
super(TornadioWebSocketHandler, self).__init__(router.application,
2728
router.request)
@@ -80,11 +81,12 @@ def on_message(self, message):
8081
self.async_callback(self.connection.raw_message)(message)
8182

8283
def on_close(self):
83-
try:
84-
self.connection.on_close()
85-
finally:
86-
self.connection.is_closed = True
87-
self.connection.stop_heartbeat()
84+
if self.connection is not None:
85+
try:
86+
self.connection.on_close()
87+
finally:
88+
self.connection.is_closed = True
89+
self.connection.stop_heartbeat()
8890

8991
def send(self, message):
9092
self.write_message(proto.encode(message))

0 commit comments

Comments
 (0)