Replies: 10 comments
-
Are you monkey patching eventlet? I don't think pymongo will work under eventlet without monkey patching. |
Beta Was this translation helpful? Give feedback.
-
Sorry for leaving that part out, yes, I am now monkey patching at the very top above all my imports. I unfortunately still get err connection refused from mongoDB. Previously I did the monkey patch at the bottom, so that may be why I got the extra stuff
|
Beta Was this translation helpful? Give feedback.
-
Unfortunately I don't use pymongo so I don't really know how to help. This could be an incompatibility between eventlet and pymongo, Socket.IO can't really cause this. Maybe try removing eventlet while keeping Socket.IO to see if that makes a difference, because your assessment that Socket.IO is causing this problem is really not possible. |
Beta Was this translation helpful? Give feedback.
-
It's okay, thank you for the help. I'm using mongoengine instead of pymongo if it makes a difference? Unfortunately, even without gevent and eventlet, the app does not work. Tinkered with MongoDB and got a little closer to finding the root; now, requests are going through on every page except the page I have my socket_io requests on. I investigated a bit with Postman and it seems that the backend is the root of the problem, as no matter what I do now, the program simply hangs when I send out a request to my DB while a socket connection is open. |
Beta Was this translation helpful? Give feedback.
-
Your log shows that you are using pymongo. This is a dependency of mongoengine. In general problems with eventlet and third party libraries happen at the bottom of the chain on the lowest level dependencies, which are often the ones that send requests out to the network. Feel free to attach a new log session that runs without eventlet and hangs. I'm pretty sure this package has no side effects that can cause your database connections to fail, but happy to take a quick look if you provide the logs. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for everything again, but unfortunately, my logs are clear on both the front and backend. The most I have is the ECONN refused. I was wondering though, upon closer inspection one of the modules I'm using has an init_app function I call near the top; would that conflict in any way, since socketio wraps the app? |
Beta Was this translation helpful? Give feedback.
-
@esot0 Flask-SocketIO does not wrap the Flask app. It just adds a middleware that acts as a request router between the Flask and Socket.IO sides. An |
Beta Was this translation helpful? Give feedback.
-
Got it, thanks for everything :) |
Beta Was this translation helpful? Give feedback.
-
Hey there! I ended up fixing the prior error with the database (dotenv was simply too low), but now I'm getting actual errors from socketio when I go to the page where I initialize socketio on the frontend. The session becomes invalid, and the request does not go through. Backend Log:
Frontend Log:
|
Beta Was this translation helpful? Give feedback.
-
You haven't configured CORS properly. Add |
Beta Was this translation helpful? Give feedback.
-
Hi there! I realized that I can't connect to my routes when I run it with flask-socketIO. Removing it, my project worked as intended. I'm a little stumped here, as I'm not quite sure what happened. They flip between CORS errors in the log, to just giving me error code 500. However, I have CORS setup extensively already, so I'm not even sure where that's coming from. Double checked my mongoDB and it does have my current IP address listed.
Here's a bit of what my backend looks like:
And frontend (react):
Socket Context
Index.js
Chat.js
Logs
(Files so this post doesn't get annoyingly long)
Server:
server_log.txt
Client:
client_log.txt
Thank you so much for any help!
Beta Was this translation helpful? Give feedback.
All reactions