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

Server: subprotocols = None is not iterable #22

Closed
mooomooo opened this issue Sep 11, 2022 · 1 comment
Closed

Server: subprotocols = None is not iterable #22

mooomooo opened this issue Sep 11, 2022 · 1 comment

Comments

@mooomooo
Copy link

mooomooo commented Sep 11, 2022

self.subprotocols = subprotocols

I've encountered a TypeError: argument of type 'NoneType' is not iterable because of this. I assume you probably want to do something similar to what you do in the Client:

self.subprotocols = subprotocols or []

(for completeness, this is happening through flask-socketio; full trace is:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 2548, in __call__ 
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.10/site-packages/flask_socketio/__init__.py", line 43, in __call__
    return super(_SocketIOMiddleware, self).__call__(environ,
  File "/usr/local/lib/python3.10/site-packages/engineio/middleware.py", line 63, in __call__
    return self.engineio_app.handle_request(environ, start_response)
  File "/usr/local/lib/python3.10/site-packages/socketio/server.py", line 604, in handle_request 
    return self.eio.handle_request(environ, start_response)
  File "/usr/local/lib/python3.10/site-packages/engineio/server.py", line 411, in handle_request 
    packets = socket.handle_get_request(
  File "/usr/local/lib/python3.10/site-packages/engineio/socket.py", line 103, in handle_get_request
    return getattr(self, '_upgrade_' + transport)(environ,
  File "/usr/local/lib/python3.10/site-packages/engineio/socket.py", line 158, in _upgrade_websocket
    return ws(environ, start_response)
  File "/usr/local/lib/python3.10/site-packages/engineio/async_drivers/threading.py", line 22, in __call__
    self.ws = Server(environ)
  File "/usr/local/lib/python3.10/site-packages/simple_websocket/ws.py", line 321, in __init__
    super().__init__(sock, connection_type=ConnectionType.SERVER,
  File "/usr/local/lib/python3.10/site-packages/simple_websocket/ws.py", line 71, in __init__
    self.handshake()
  File "/usr/local/lib/python3.10/site-packages/simple_websocket/ws.py", line 336, in handshake 
    self.connected = self._handle_events()
  File "/usr/local/lib/python3.10/site-packages/simple_websocket/ws.py", line 183, in _handle_events 
    self.subprotocol = self.choose_subprotocol(event)
  File "/usr/local/lib/python3.10/site-packages/simple_websocket/ws.py", line 340, in choose_subprotocol
    if subprotocol in self.subprotocols:
TypeError: argument of type 'NoneType' is not iterable

)

@miguelgrinberg
Copy link
Owner

Thanks, this should now be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants