R
Railway•11mo 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•11mo ago
Project ID: 4cc29972-e583-4641-81d0-26868fcc02e7
jorgemayto
jorgemaytoOP•11mo ago
4cc29972-e583-4641-81d0-26868fcc02e7
Brody
Brody•11mo ago
we are going to need more information than "the server doesn't work"
jorgemayto
jorgemaytoOP•11mo ago
The error I provided is all that is shown in my logs
Brody
Brody•11mo ago
are you using gunicorn when on railway?
jorgemayto
jorgemaytoOP•11mo ago
yeah: web: gunicorn main:app
Brody
Brody•11mo ago
have you confirmed it's working locally when starting your app with that command?
jorgemayto
jorgemaytoOP•11mo ago
Just tested it, it doesn't appear to work, so im guessing its an issue on my side
Brody
Brody•11mo ago
does gunicorn even natively support websockets? maybe you want to use Daphne instead?
jorgemayto
jorgemaytoOP•11mo ago
I'll check right now
Brody
Brody•11mo 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•11mo ago
Im currently facing the same problem. Its giving me headaches 🧠
No description
Brody
Brody•11mo ago
well the things ive already said would apply to you, so give daphne a try
Eminem
Eminem•11mo ago
Let me do so, will brb
jorgemayto
jorgemaytoOP•11mo ago
I user geventlet and it started working (with gunicorn) This is the command: web: gunicorn --worker-class eventlet -w 1 main:app
King Jahad
King Jahad•11mo ago
Will this be considered a good solution? Will we be able to use both HTTP and TCP traffic?
Brody
Brody•11mo ago
since when did gunicorn without geventlet support tcp??
jorgemayto
jorgemaytoOP•11mo ago
idk it's one of the first things I found that worked so I just kept it for now
Want results from more Discord servers?
Add your server