I can’t connect with Postman under the Debugger mode status.
This is the screenshot of Postman error.
Postman disconnected error
This is my error report from the Pycharm project:
WebSocket HANDSHAKING /ws/chat/a1/ [127.0.0.1:56306]
Exception inside application: subclasses of LazyObject must provide a _setup() method
Traceback (most recent call last):
File "D:pycharm_projectsweb_technologies2024WSServer.venvLibsite-packagesdjangocontribstaticfileshandlers.py", line 101, in __call__
return await self.application(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:pycharm_projectsweb_technologies2024WSServer.venvLibsite-packageschannelsrouting.py", line 62, in __call__
return await application(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:pycharm_projectsweb_technologies2024WSServer.venvLibsite-packageschannelssessions.py", line 47, in __call__
return await self.inner(dict(scope, cookies=cookies), receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:pycharm_projectsweb_technologies2024WSServer.venvLibsite-packageschannelssessions.py", line 261, in __call__
await wrapper.resolve_session()
File "D:pycharm_projectsweb_technologies2024WSServer.venvLibsite-packageschannelssessions.py", line 170, in resolve_session
self.scope["session"]._wrapped = await database_sync_to_async(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
routing.py
from django.urls import re_path
from chat import consumers
websocket_urlpatterns = [
re_path(r'ws/chat/(?P<room_name>w+)/$', consumers.ChatConsumer.as_asgi()),
]
asgi.py
import os
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
from chat.routing import websocket_urlpatterns
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
# Initialize Django ASGI application early to ensure the AppRegistry
# is populated before importing code that may import ORM models.
django_asgi_app = get_asgi_application()
application = ProtocolTypeRouter({
"http": django_asgi_app,
"websocket": AuthMiddlewareStack(
URLRouter(
websocket_urlpatterns
)
),
})
New contributor
Ting Long is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2