Add more robust error handling for Hybi and Client and emit error events when the protocol goes wrong.