Exception in ASGI application - 'NoneType' object is not subscriptable
See original GitHub issueHello, I have ‘NoneType’ error on asgi_send method, im not sure for why this happens:
[2018-11-07 22:13:39 -0500] [2868] [ERROR] Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/uvicorn/protocols/websockets/websockets_impl.py", line 140, in run_asgi
result = await asgi(self.asgi_receive, self.asgi_send)
File "/usr/local/lib/python3.6/dist-packages/channels/sessions.py", line 175, in __call__
return await self.inner(receive, self.send)
File "/usr/local/lib/python3.6/dist-packages/channels/middleware.py", line 41, in coroutine_call
await inner_instance(receive, send)
File "/usr/local/lib/python3.6/dist-packages/channels/consumer.py", line 54, in __call__
await await_many_dispatch([receive, self.channel_receive], self.dispatch)
File "/usr/local/lib/python3.6/dist-packages/channels/utils.py", line 50, in await_many_dispatch
await dispatch(result)
File "/usr/local/lib/python3.6/dist-packages/channels/consumer.py", line 67, in dispatch
await handler(message)
File "/usr/local/lib/python3.6/dist-packages/channels/generic/websocket.py", line 173, in websocket_connect
await self.connect()
File "/home/deploy/xxxxxx/app/consumers.py", line 314, in connect
await self.accept()
File "/usr/local/lib/python3.6/dist-packages/channels/generic/websocket.py", line 186, in accept
await super().send({"type": "websocket.accept", "subprotocol": subprotocol})
File "/usr/local/lib/python3.6/dist-packages/channels/consumer.py", line 75, in send
await self.base_send(message)
File "/usr/local/lib/python3.6/dist-packages/channels/sessions.py", line 226, in send
return await self.real_send(message)
File "/usr/local/lib/python3.6/dist-packages/uvicorn/protocols/websockets/websockets_impl.py", line 170, in asgi_send
self.scope["server"][0],
TypeError: 'NoneType' object is not subscriptable
Any ideas?
Django==2.1.3 channels==2.1.5 channels_redis==2.3.1 gunicorn==19.9.0 uvicorn==0.3.20
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (11 by maintainers)
Top Results From Across the Web
TypeError: 'NoneType' object is not subscriptable
NoneType is the type of the None object which represents a lack of value, for example, a function that does not explicitly return...
Read more >tiangolo/fastapi - Gitter
Exception in ASGI application Traceback (most recent call last): File ... await response(scope, receive, send) TypeError: 'NoneType' object is not callable.
Read more >'NoneType' object has no attribute 'query_params'
Somehow I'm getting this and I'm not sure how to resolve it: `Exception in ASGI application. Traceback (most recent call last):
Read more >'NoneType' object is not subscriptable? - python
The print() function returns None . You are trying to index None. You can not, because 'NoneType' object is not subscriptable . Put...
Read more >typeerror: 'response' object is not subscriptable
The "TypeError: object is not subscriptable" means that we are using square brackets to either access a key in a specific object or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Its really easy to see how this is happening.
get_local_addr(transport)
returns None if the sockname key is not set. You just follow that code to where it gets set on the scope and its taking [0] from None. What should that function return when sockname is not set (it appears to never be set) instead of None?What is a simple means of reproducing the issue in order to debug/test the solution? According to the ASGI spec, the
server
field is optional and defaults toNone
. It may be clear what is happening, but we need a way to reproduce the behaviour to determine a generic solution.