2

I have a flask + Gevent-socketio mini website. Is launched:

app = Flask(__name__)
app.debug = True

@werkzeug.serving.run_with_reloader
def runServer():
    print 'Listening on %s...' % WEB_PORT
    ws = SocketIOServer(('0.0.0.0', WEB_PORT),
        SharedDataMiddleware(app, {}),
        resource="socket.io",
        policy_server=False)

    ws.serve_forever()

However, when a error happend in my views, it output

<pre style="word-wrap: break-word; white-space: pre-wrap;">Internal Server Error</pre>

instead of show the werkzeug debugger. Also, my custom @app.errorhandler(500) is not called.

This happend on using Gevent-socketio, regular flask website works fine.

I wonder what is handling the error and canceling the default flask behavior...

Paco
  • 4,520
  • 3
  • 29
  • 53
mamcx
  • 15,916
  • 26
  • 101
  • 189

2 Answers2

2

I've recently solved this, Werkzeug debuggger can be modified to work with socket.io namespaces (and auto-reloading will also work), see here and enjoy:

https://github.com/aldanor/SocketIO-Flask-Debug

aldanor
  • 3,371
  • 2
  • 26
  • 26
1

To see werkzeug debugger you must serve all http request by default server with standart middleware stack.

But you launched separate SocketIOServer for serve websockets requests.

example for flask and gevent_socketio usage

estin
  • 3,051
  • 1
  • 24
  • 31
  • I do that but get hit by the error: KeyError: 'socketio'. I think was related to https://github.com/abourget/gevent-socketio/issues/63 so I rollback to several socket.io clients, but not work. However, it's work if I left it as before. So using this solution get the error and socket io not work. – mamcx Dec 20 '12 at 20:53