MrJoes/tornadio2 — Issue #32: uncaught exception breaks connection - poss due to heartbeat breaking chatty connection?
Author: hjwp
Created: 2012-03-07 15:55:55+00:00
State: open

Hey,

we've noticed several `Uncaught exception in /socket.io/1/websocket/` types of errors in our logs. We think it tends to happen when there's a lot of small bits data being transmitted between the client and server in quick succession.

Here's a minimal repro, which should crash within a minute or so... :

```python

from os import path as op
import logging
from tornado import web
from tornadio2 import SocketConnection, TornadioRouter, SocketServer
ROOT = op.normpath(op.dirname(__file__))

class IndexHandler(web.RequestHandler):
"""Regular HTTP handler to serve the ping page"""
def get(self):
self.render('index.html')

class SocketIOHandler(web.RequestHandler):
def get(self):
self.render('../socket.io.js')

class PongConnection(SocketConnection):
def on_message(self, message):
print message
self.send('pong')

PingRouter = TornadioRouter(PongConnection,
dict(enabled_protocols=['websocket', 'xhr-polling',
'jsonp-polling', 'htmlfile']))
application = web.Application(
PingRouter.apply_routes([
(r"/", IndexHandler),
(r"/socket.io.js", SocketIOHandler)
]),
flash_policy_port = 843,
flash_policy_file = op.join(ROOT, 'flashpolicy.xml'),
socket_io_port = 8001
)

if __name__ == "__main__":
# watch logs for error
logging.basicConfig(filename='repro.log', level=logging.DEBUG, format='%(asctime)s %(levelname)s:%(message)s')
SocketServer(application)
```

```html

Minimal repro

```