R
Railway•6mo ago
andrekakon

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•6mo ago
Project ID: 4cc29972-e583-4641-81d0-26868fcc02e7
andrekakon
andrekakon•6mo ago
4cc29972-e583-4641-81d0-26868fcc02e7
Brody
Brody•6mo ago
we are going to need more information than "the server doesn't work"
andrekakon
andrekakon•6mo ago
The error I provided is all that is shown in my logs
Brody
Brody•6mo ago
are you using gunicorn when on railway?
andrekakon
andrekakon•6mo ago
yeah: web: gunicorn main:app
Brody
Brody•6mo ago
have you confirmed it's working locally when starting your app with that command?
andrekakon
andrekakon•6mo ago
Just tested it, it doesn't appear to work, so im guessing its an issue on my side
Brody
Brody•6mo ago
does gunicorn even natively support websockets? maybe you want to use Daphne instead?
andrekakon
andrekakon•6mo ago
I'll check right now
Brody
Brody•6mo 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•6mo ago
Im currently facing the same problem. Its giving me headaches 🧠
No description
Brody
Brody•6mo ago
well the things ive already said would apply to you, so give daphne a try
Eminem
Eminem•6mo ago
Let me do so, will brb
andrekakon
andrekakon•6mo 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•6mo ago
Will this be considered a good solution? Will we be able to use both HTTP and TCP traffic?
Brody
Brody•6mo ago
since when did gunicorn without geventlet support tcp??
andrekakon
andrekakon•6mo 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
More Posts