inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

asgi 배포관련

해결됨

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

안녕하세요 선생님 강의를 다 듣고 본 강의를 기반으로 chat bot을 프로젝트로 배포하려고 하는 수강생입니다. aws를 통해서 배포하려고 자료를 찾아보는데 대부분 wsgi기반의 웹에 대해서 나와있더라고요.. 혹시 asgi를 기반으로 하는 웹은 어느경로를 통해서 배포하는게 나을지 물어볼 수 있을까요?

  • python
  • django
  • django-channels
이태경 댓글 1 좋아요 0 조회수 616

채팅할때 유저인증을 어떻게 처리해야 할까요??

미해결

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

다른 기능은 전부 스프링 서버에 구현 되어있고 장고는 채팅 서버만 구현되어있습니다. 이럴때 유저인증을 어떻게 해야할까요..

  • python
  • django
  • django-channels
kth050213 댓글 1 좋아요 0 조회수 586

run_test_hello_channel.py 11002 Error

미해결

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

안녕하세요 강사님 run_test_hello_channel.py을 실행했더니 생기는 오류에 대해서 질문드립니다. 실행을 했을시 True가 나올때도 있지만 Traceback (most recent call last): File "D:\23_project\django_channels\venv\lib\site-packages\redis\asyncio\connection.py", line 709, in connect await self._connect() File "D:\23_project\django_channels\venv\lib\site-packages\redis\asyncio\connection.py", line 744, in _connect reader, writer = await asyncio.open_connection( File "C:\Users\honge\AppData\Local\Programs\Python\Python310\lib\asyncio\streams.py", line 47, in open_connection transport, _ = await loop.create_connection( File "C:\Users\honge\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1016, in create_connection infos = await self._ensure_resolved( File "C:\Users\honge\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 1395, in _ensure_resolved return await loop.getaddrinfo(host, port, family=family, type=type, File "C:\Users\honge\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 855, in getaddrinfo return await self.run_in_executor( File "C:\Users\honge\AppData\Local\Programs\Python\Python310\lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "C:\Users\honge\AppData\Local\Programs\Python\Python310\lib\socket.py", line 955, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno 11002] getaddrinfo failed During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\23_project\django_channels\run_test_hello_channel.py", line 23, in <module> asyncio.run(main()) File "C:\Users\honge\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\honge\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete return future.result() File "D:\23_project\django_channels\run_test_hello_channel.py", line 16, in main await channel_layer.send('hello', message_dict) File "D:\23_project\django_channels\venv\lib\site-packages\channels_redis\core.py", line 218, in send await connection.zremrangebyscore( File "D:\23_project\django_channels\venv\lib\site-packages\redis\asyncio\client.py", line 484, in execute_command conn = self.connection or await pool.get_connection(command_name, **options) File "D:\23_project\django_channels\venv\lib\site-packages\redis\asyncio\connection.py", line 1525, in get_connection await connection.connect() File "D:\23_project\django_channels\venv\lib\site-packages\redis\asyncio\connection.py", line 715, in connect raise ConnectionError(self._error_message(e)) redis.exceptions.ConnectionError: Error 11002 connecting to redis-10519.c294.ap-northeast-1-2.ec2.cloud.redislabs.com:10519. 11002. 위와 같은 에러가 발생할 때도 있습니다. 혹시 지역이 일본으로 해놓아 거리때문에 생기는 이슈또는 너무 많은 요청에 의한 이슈일까요??

  • python
  • django
  • django-channels
honge7694 댓글 1 좋아요 0 조회수 606

채팅방 퇴장시 퇴장 메시지 출력 안됨

해결됨

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

안녕하세요. 채팅방에서 유저가 퇴장했을때 퇴장 했다는 메시지가 보여지질 않습니다. 그래서 disconnect, chat_user_leave method 에 print 를 추가해서 확인을 해보니 disconnect method 에서 is_last_leave 는 True 가 찍혀 채널 레이어 그룹에 type=‘chat.user.leave’ 메시지를 보내는 것은 되는거 같은데, 그 후 chat_user_leave method 가 실행이 안되는거 같습니다. (추가한 print 가 실행이 안되서 터미널에 아무것도 찍히지 않습니다.) 이 부분이 원인거 같은데 무슨 문제인지 어떻게 해결해야될지 모르겠어서 질문드립니다.

  • python
  • django
  • django-channels
손해창 댓글 3 좋아요 0 조회수 712

run_test_hello_channel.py 실행 no module named 'channel_redis' 오류 발생

해결됨

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

m1 mac에서 강의를 듣고있습니다. env에서 channel_layer_redis 값을 파싱하는 것까지는 잘 따라왔는데 run_test_hello_channel.py 에서 해당 오류가 발생하네요 강사님 github에 있는 코드 그대로 복사해서 붙였는데도 오류가 나서 어디서부터 해결해야 할 지 모르겠습니다!도와주세요 ㅜㅜ import asyncio import os import django from channels.layers import get_channel_layer os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings"django.setup() async def main(): channel_layer = get_channel_layer() message_dict = {'content': 'world'} await channel_layer.send('hello', message_dict) response_dict = await channel_layer.receive('hello') is_equal = message_dict == response_dict print("송신/수신 데이터가 같습니까?", is_equal) asyncio.run (main()) 터미널 결과는 다음과 같습니다. (webchat) tk_mac@itaegyeong-ui-MacBookAir webchat % python run_test_hello_channel.py Traceback (most recent call last): File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/site-packages/channels/layers.py", line 65, in make backend backend_class = import_string(self.configs[name]["BACKEND"]) File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/site-packages/django/utils/module_loading.py", line 30, in import_string return cached_import(module_path, class_name) File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/site-packages/django/utils/module_loading.py", line 15, in cached_import module = import_module(module_path) File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/importlib/__init__.py", line 126, in import_module return bootstrap. gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in gcd import File "<frozen importlib._bootstrap>", line 1027, in find and_load File "<frozen importlib._bootstrap>", line 992, in find and_load_unlocked File "<frozen importlib._bootstrap>", line 241, in call with_frames_removed File "<frozen importlib._bootstrap>", line 1050, in gcd import File "<frozen importlib._bootstrap>", line 1027, in find and_load File "<frozen importlib._bootstrap>", line 1004, in find and_load_unlocked ModuleNotFoundError: No module named 'channel_redis' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/tk_mac/github/webchat/run_test_hello_channel.py", line 22, in <module> asyncio.run (main()) File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run _until_complete(main) File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/Users/tk_mac/github/webchat/run_test_hello_channel.py", line 12, in main channel_layer = get_channel_layer() File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/site-packages/channels/layers.py", line 357, in get_channel_layer return channel_layers[alias] File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/site-packages/channels/layers.py", line 78, in getitem self.backends[key] = self.make_backend(key) File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/site-packages/channels/layers.py", line 44, in make_backend return self._make_backend(name, config) File "/Users/tk_mac/opt/anaconda3/envs/webchat/lib/python3.10/site-packages/channels/layers.py", line 69, in make backend raise InvalidChannelLayerError( channels.exceptions.InvalidChannelLayerError: Cannot import BACKEND 'channel_redis.core.RedisChannelLayer' specified for default

  • python
  • django
  • django-channels
이태경 댓글 2 좋아요 0 조회수 641

채팅방 삭제 관련 오류가 뭐때문인지 모르겠습니다..

미해결

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

안녕하세요 새 프로젝트를 만들어서 강사님 강의대로 구현했을 때에는 에러가 뜨지 않았는데요 제가 하던 간단한 프로젝트에서 채팅기능 추가하려고 하니까, 에러가 나네요.. 강의 동영상 7분전까지는 오류없이 채팅방 삭제가 잘 되었는데요. 8분쯤 나오는 채팅방 삭제에 따른 웹소켓 연결 끊기 부분에서 잘못된것 같습니다. 채팅방을 만든 상태에서 채팅방을 삭제하면 WebSocket DISCONNECT /ws/chat/11/chat/ [127.0.0.1:54878] Task exception was never retrieved future: <Task finished name='Task-335' coro=<Connection.disconnect() done, defined at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:723> exception=RuntimeError("Task <Task pending name='Task-335' coro=<Connection.disconnect() running at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:736>> got Future <Future pending> attached to a different loop")> Traceback (most recent call last): File "/Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py", line 736, in disconnect await self._writer.wait_closed() # type: ignore[union-attr] File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/streams.py", line 344, in wait_closed await self._protocol._get_close_waiter(self) RuntimeError: Task <Task pending name='Task-335' coro=<Connection.disconnect() running at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:736>> got Future <Future pending> attached to a different loop Task exception was never retrieved future: <Task finished name='Task-336' coro=<Connection.disconnect() done, defined at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:723> exception=RuntimeError("Task <Task pending name='Task-336' coro=<Connection.disconnect() running at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:736>> got Future <Future pending> attached to a different loop")> Traceback (most recent call last): File "/Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py", line 736, in disconnect await self._writer.wait_closed() # type: ignore[union-attr] File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/streams.py", line 344, in wait_closed await self._protocol._get_close_waiter(self) RuntimeError: Task <Task pending name='Task-336' coro=<Connection.disconnect() running at /Users/hugo/Desktop/venv/chaegbang/lib/python3.10/site-packages/redis/asyncio/connection.py:736>> got Future <Future pending> attached to a different loop 이렇게 나옵니다. 검색해도 잘 모르겠습니다... 새로운 프로젝트만들어서 했을 때에는 이런 오류가 안떴는데 패키지 버전문제일까요??

  • python
  • django
  • django-channels
AeGin 댓글 1 좋아요 0 조회수 618

django-rest-framework에 channels를 적용하고 싶습니다.

미해결

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

선생님, 안녕하세요~ django rest framework와 함께 django channels를 사용하고 싶어서 질문드리게되었습니다! liveblog 실습 부분까지는 무난하게 따라올 수 있었는데요, drf와 django channels를 동시에 사용해보고 싶어서, 예전에 작업해둔 drf 적용한 project에서 channels를 추가하여 실행해보려고 했는데, asgi를 적용하고 나서부터 runserver 시 TypeError: object HttpResponse can't be used in 'await' expression 라는 에러메시지를 받습니다. channels 공식 문서에 있는 djangochannelsrestframework 라는 프로젝트와 channels-api 라는게 있던데 아직 적용해보지는 않았습니다 drf와 channels를 함께 사용하는데에 추천하시는 라이브라리나 이용방법이 있을까요? 검색만으로는 막막하여 정리되지 않은 상태에서 질문을 드리는 것 같아 죄송하네요. 좋은 강의 항상 감사합니다!!!

  • django
  • python
  • django-channels
  • django-channels
김성겸 댓글 1 좋아요 0 조회수 623

웹소켓 동작 방식에 대해 질문이 있습니다.

미해결

파이썬/장고로 웹채팅 서비스 만들기 (Feat. Channels) - 기본편

웹소켓부분은 처음 배워봐서 조금 헷갈리네요 ㅠㅠ app의 views에서 렌더링 된 echo_page.html은 클라이언트를 의미 그 클라이언트에서 ws객체를 이용해 여러가지 이벤트 핸들러 처리와 메세지를 웹소켓 서버(ws:// localhost:8000/ws/echo/)로 전송할 수 있음 웹소켓 서버로 전송된 메세지는 routing.py에 등록된 path에 맞게 매칭된 Consumer를 호출 호출된 Consumer는 receive 오버라이딩을 통해 클라이언트에서 보낸 메세지에 대해 후속 처리 이 프로세스로 흘러가는게 맞나요? 한 가지 더 궁금한 점은 이번 예제의 EchoConsumer에서 send로 보낸 메세지는 단순히 '메세지 전송 요청을 보냈던' 클라이언트에게 되돌아가는데 만약 서로 다른 여러 클라이언트에서 요청이 들어오면 각 클라이언트는 어떻게 구별하나요? http의 헤더처럼 요청 주체를 구별하는 방법이 웹소켓 통신에도 따로 있는건가요?

  • django-channels
  • django
  • python
양념치킨 댓글 2 좋아요 0 조회수 721

인기 태그

인프런 TOP Writers

주간 인기글