dpallot / simple-websocket-server

A python based websocket server that is simple and easy to use.
951 stars 319 forks source link

Overzealous exception handling during handshake #56

Open adrian-the-git opened 7 years ago

adrian-the-git commented 7 years ago

When an exception occurs inside handleConnected, it's re-raised inside _handleData and then caught again inside the main serveForever loop.

The connection is then silently closed (no traceback is shown) so this can make it tricky to find the culprit of a misbehaved websocket. My sense would be to replace instances of raise Exception("Some websocketty thing") with raise WebSocketException("Some websocketty thing") so that they can be explicitly caught in the top-level select loop, and implementors of the WebSocket class will find their code crashing early and often :grimacing:

I'd send a pull request, but I'm not sure I fully grok all the avenues of control flow wherein it would be advantageous to do something different, nor am I equipped to test it :confused: