Implementation in Django #744
Replies: 4 comments
-
Are you importing views.py somewhere in your application? The file needs to be imported for the handlers to be registered with the server. |
Beta Was this translation helpful? Give feedback.
-
So, the situation is the following: Another question I would like to ask is about the example you uploaded here on Github. There is no eventlet listeners and / or similar in your wsgi file. How does the socket server listen for events? To be safe, I copied your example comma by comma and the socket server never started I look forward to hearing from you |
Beta Was this translation helpful? Give feedback.
-
Ok, after a few minutes of banging my head on the table after my last answer, I thought: Why not try setting the same port as the development server in the eventlet server? and it worked! I was simply convinced from the beginning that the listening port of the eventlet server should be different from that of the development server, but evidently it wasn't. |
Beta Was this translation helpful? Give feedback.
-
@Marco-Gtto I think part of your misunderstanding comes from the fact that you are thinking there are two servers. There's only one server and in terms of WSGI there is only one WSGI application. In your The approach I've taken in the Django example in this repository is cleaner, in my opinion. In the wsgi.py file all I'm doing is creating the combined WSGI application. This would allow you to run the application with any web server. If you wanted to run the application under eventlet, then you could write a import eventlet
import eventlet.wsgi
from myproject.wsgi import application
eventlet.wsgi.server(eventlet.listen(('', 5000)), application) But if you prefer to use Gunicorn, you can do that, without having to modify your source code: gunicorn -b :5000 -k eventlet -w 1 myproject.wsgi The answer to your question regarding the "missing" eventlet server is that the application is an application, not a web server. Which web server you run it on is not something that needs to be expressed inside the application. To run my example under eventlet you can use any of the two approaches I showed you above. Also for convenience, I have added a customized |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi @miguelgrinberg,
I am developing a project with Django, in which I have recently started integrating socket.io.
I followed the documentation and your specific examples about it, getting to this point:
views.py
wsgi.py
In my project I created an app that will only take care of updating the database in relation to the data received via socket. I have currently started writing code for this in views.py, although I would like to create a dedicated file for this purpose. Essentially the problem is that in the console I read the following strings:
however the event handlers in views.py seem not to exist, as after connection I don't receive any message in the console.
I'm not actually able to figure out if I need to invoke something somewhere or add more in wsgi to get the event handlers in question to work.
I hope for some advice that can help me continue.
Thanks in advance
Marco
Beta Was this translation helpful? Give feedback.
All reactions