'AsgiRequest' object has no attribute 'register'
See original GitHub issueHello,
After following the installation instructions, and using the example in the README with django==2.2.1
and django-channels-graphql-ws==0.2.0
on Python 3.7.3, when making any subscription operation:
subscription {
mySubscription {event}
}
{
"errors": [
{
"message": "'AsgiRequest' object has no attribute 'register'"
}
],
"data": null
}
Traceback:
Traceback (most recent call last):
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/graphql/execution/executor.py", line 447, in resolve_or_error
return executor.execute(resolve_fn, source, info, **args)
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/graphql/execution/executors/sync.py", line 16, in execute
return fn(*args, **kwargs)
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/graphene_django/debug/middleware.py", line 56, in resolve
promise = next(root, info, **args)
File "/***.py", line 86, in resolve
result = next(root, info, **args)
File "/***.py", line 37, in resolve
return next(root, info, **args)
File "/***.py", line 8, in resolve
return result.get()
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/promise/promise.py", line 510, in get
return self._target_settled_value(_raise=True)
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/promise/promise.py", line 514, in _target_settled_value
return self._target()._settled_value(_raise)
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/promise/promise.py", line 224, in _settled_value
reraise(type(raise_val), raise_val, self._traceback)
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/six.py", line 693, in reraise
raise value
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/promise/promise.py", line 487, in _resolve_from_executor
executor(resolve, reject)
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/promise/promise.py", line 754, in executor
return resolve(f(*args, **kwargs))
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/graphql/execution/middleware.py", line 76, in make_it_promise
return next(*args, **kwargs)
File "/.cache/pypoetry/virtualenvs/WcnE4_vK-py3.7/lib/python3.7/site-packages/channels_graphql_ws/graphql_ws.py", line 425, in _subscribe
register = info.context.register
AttributeError: 'AsgiRequest' object has no attribute 'register'
While I can see where the ‘register’ attribute is needed: https://github.com/datadvance/DjangoChannelsGraphqlWs/blob/master/channels_graphql_ws/graphql_ws.py#L425, I can’t see what could have caused it to be deleted from the context before going through Subscription._subscribe
.
Do you have any idea what could lead to that situtation, and how to fix it?
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
'ASGIRequest' object has no attribute 'get' in daphne django ...
@JPG Yes, as fastapi can't run itself. It needs either uvicorn or daphne (which runs under django) to run. Now I beg you...
Read more >'ASGIRequest' object has no attribute 'get' in daphne django ...
Coding example for the question Getting AttributeError: 'ASGIRequest' object has no attribute 'get' in daphne django-django.
Read more >WSGIRequest' object has no attribute 'get' error after submitting
I have the following codes: models.py class Job(models.Model): datetime = models.DateTimeField(default=timezone.now) associateddevice ...
Read more >Django 2.0 and AsgiRequest Error - Google Groups
AttributeError : 'AsgiRequest' object has no attribute 'user'. So I'm hoping someone has an insight into its root cause and, maybe, a solution....
Read more >Tutorial: Create a real-time web game with Django Channels ...
return <li key={game.id} className="list-group-item"> ... and log in on each browser with a different user (or register a new player if you only...
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
Hey @rigelk ,
AsgiRequest
is used inchannels.http.AsgiHandler
. If ahttp
argument is not provided in channels.routing.ProtocolTypeRouter, it will default to the Django view system’s ASGI interface,channels.http.AsgiHandler
.So
AsgiHandler
is done specifically to work with ordinary normal Django views by default. In our example we don’t providehttp
, we providewebsocket
argument for websocket connections:In this way our
GraphqlWsConsumer
from example does not useAsgiRequest
andAsgiHandler
for HTTP, because AsyncJsonWebsocketConsumer doesn’t do that. The only HTTP path (after whichAsgiRequest
will be created) in our example is the path tographiql
, but it is not connected toGraphqlWsConsumer
:Could you show how you configure
ProtocolTypeRouter
andurlpatterns
? What kind of requests do you send to the server via HTTP? This could help reproduce this problem.@Thibaut-Fatus would you mind sharing a bit how you implemented this in a react app