S
S
Sergey Eremin2020-12-25 03:41:51
Django
Sergey Eremin, 2020-12-25 03:41:51

How to solve error while preparing websocket on django 3.1?

Preparing websoketa for django 3.1. I use the recipe: https://alex-oleshkevich.medium.com/websockets-in-... . And everything is clear, but something does not work. Falls by mistake:

Traceback (most recent call last):
  File "C:\Python\3.8\lib\wsgiref\handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "C:\Python\ENV\myapp\lib\site-packages\django\contrib\staticfiles\handlers.py", line 76, in __call__
    return self.application(environ, start_response)
TypeError: wsgi() missing 1 required positional argument: 'send'


And what kind of 'send' is and where to get it from - I don't understand. True, because development is carried out in PyCharm under Windows, then I run it not through asgi.py , but through wsgi.py ... (third-party application servers are not available, such as unicorn under Windows), I tried to use waitress (a wrapper over wsgi) - the effect is the same :
TypeError: wsgi() missing 1 required positional argument: 'send'
I prepare Waitress like this: next to manage.py , I create server.py :
from waitress import serve
from myapp.wsgi import application

if __name__ == '__main__':
    serve(application, port='5678')


Run $ python server.pyor waitress-serve --port=5678 myapp.wsgi:application-- same error with 'send' argument...

PS I know about channels and django-websocket . But they also require asgi . I will be glad if you tell me other recipes. You don't need to listen to the websocket. Only "say. The main thing is that you can use and test in dev under Windows (and preferably without leaving PyCharm)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-12-25
@Sergei_Erjemin

The "recipe" clearly states that ASGI is needed, and not WSGI protocol
PS when I need a websocket in django with WSGI, I just put aiohttp next to it, which I launched via custom command

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question