Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getting stackoverflow error on disconnect() #312

Closed
piyush121 opened this issue Aug 23, 2016 · 3 comments
Closed

getting stackoverflow error on disconnect() #312

piyush121 opened this issue Aug 23, 2016 · 3 comments
Assignees
Labels

Comments

@piyush121
Copy link

On the flask server side I am using this code -

@socketio.on('disconnect', namespace='/rank')
def test_disconnect():
    print('Client disconnected')
    disconnect()

And getting following error when client sends a disconnect -

File "manage.py", line 78, in test_disconnect
    disconnect(silent = True)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/flask_socketio/__init__.py", line 708, in disconnect
    namespace=flask.request.namespace)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/socketio/server.py", line 277, in disconnect
    namespace=namespace))
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/socketio/server.py", line 362, in _send_packet
    self.eio.send(sid, encoded_packet, binary=False)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/engineio/server.py", line 163, in send
    socket.send(packet.Packet(packet.MESSAGE, data=data, binary=binary))
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/engineio/socket.py", line 62, in send
    self.close(wait=False, abort=True)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/engineio/socket.py", line 101, in close
    self.server._trigger_event('disconnect', self.sid, async=False)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/engineio/server.py", line 349, in _trigger_event
    return self.handlers[event](*args)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/socketio/server.py", line 463, in _handle_eio_disconnect
    self._handle_disconnect(sid, '/')
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/socketio/server.py", line 387, in _handle_disconnect
    self._trigger_event('disconnect', n, sid)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/socketio/server.py", line 426, in _trigger_event
    return self.handlers[namespace][event](*args)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/flask_socketio/__init__.py", line 205, in _handler
    with app.request_context(self.server.environ[sid]):
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/flask/app.py", line 1944, in request_context
    return RequestContext(self, environ)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/flask/ctx.py", line 242, in __init__
    self.url_adapter = app.create_url_adapter(self.request)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/flask/app.py", line 1771, in create_url_adapter
    server_name=self.config['SERVER_NAME'])
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/werkzeug/routing.py", line 1327, in bind_to_environ
    query_args=query_args)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/werkzeug/routing.py", line 1241, in bind
    url_scheme, path_info, default_method, query_args)
  File "/home/ubuntu/miniconda3/lib/python3.5/site-packages/werkzeug/routing.py", line 1359, in __init__
    self.server_name = to_unicode(server_name)
RecursionError: maximum recursion depth exceeded

I appreciate your time in seeing this issue :)

@miguelgrinberg
Copy link
Owner

The problem is that you are calling disconnect from a disconnect handler function. When the disconnect handler is invoked, the client has already been disconnected, the handler is supposed to be used for application specific cleanup.

That said, I will look into detecting the recursive disconnect and avoiding the crash.

@miguelgrinberg miguelgrinberg self-assigned this Aug 23, 2016
@piyush121
Copy link
Author

I couldn't agree more. You're awesome !
Thanks a lot!

miguelgrinberg added a commit to miguelgrinberg/python-engineio that referenced this issue Sep 4, 2016
miguelgrinberg added a commit to miguelgrinberg/python-socketio that referenced this issue Sep 4, 2016
miguelgrinberg added a commit to miguelgrinberg/python-socketio that referenced this issue Sep 4, 2016
@miguelgrinberg
Copy link
Owner

The commits referenced above I think address this problem.

KoraLinSar pushed a commit to KoraLinSar/python-socketio that referenced this issue Aug 24, 2022
KoraLinSar pushed a commit to KoraLinSar/python-socketio that referenced this issue Aug 24, 2022
Watcher919 pushed a commit to Watcher919/python-socketio that referenced this issue Sep 1, 2024
Watcher919 pushed a commit to Watcher919/python-socketio that referenced this issue Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants