R
Railway•9mo ago
jorgemayto

SocketIO and Flask Rest API

I created a socketio flask rest api and it works great locally for retriving and sending data through the websockets, but as soon as I upload my code onto the railway server, the server doesn't work with my websockets. Is there any special configuration I need to do? [2024-01-09 06:21:11 +0000] [7] [CRITICAL] WORKER TIMEOUT (pid:11) [2024-01-09 06:21:11 +0000] [11] [INFO] Worker exiting (pid: 11) [2024-01-09 06:21:12 +0000] [7] [WARNING] Worker with pid 11 was terminated due to signal 9 [2024-01-09 06:21:12 +0000] [22] [INFO] Booting worker with pid: 22 Invalid session MLd5ydxTdW6sDXnBAAAA (further occurrences of this error will be logged with level INFO)
18 Replies
Percy
Percy•9mo ago
Project ID: 4cc29972-e583-4641-81d0-26868fcc02e7
jorgemayto
jorgemayto•9mo ago
4cc29972-e583-4641-81d0-26868fcc02e7
Brody
Brody•9mo ago
we are going to need more information than "the server doesn't work"
jorgemayto
jorgemayto•9mo ago
The error I provided is all that is shown in my logs
Brody
Brody•9mo ago
are you using gunicorn when on railway?
jorgemayto
jorgemayto•9mo ago
yeah: web: gunicorn main:app
Brody
Brody•9mo ago
have you confirmed it's working locally when starting your app with that command?
jorgemayto
jorgemayto•9mo ago
Just tested it, it doesn't appear to work, so im guessing its an issue on my side
Brody
Brody•9mo ago
does gunicorn even natively support websockets? maybe you want to use Daphne instead?
jorgemayto
jorgemayto•9mo ago
I'll check right now
Brody
Brody•9mo ago
I think the start command for Daphne would be
daphne main:app --bind 0.0.0.0 --port $PORT
daphne main:app --bind 0.0.0.0 --port $PORT
so add daphne to your requirements.txt and then update the web command in your Procfile to that command above
Eminem
Eminem•9mo ago
Im currently facing the same problem. Its giving me headaches 🧠
No description
Brody
Brody•9mo ago
well the things ive already said would apply to you, so give daphne a try
Eminem
Eminem•9mo ago
Let me do so, will brb
jorgemayto
jorgemayto•8mo ago
I user geventlet and it started working (with gunicorn) This is the command: web: gunicorn --worker-class eventlet -w 1 main:app
Want results from more Discord servers?
Add your server