#SocketIO and Flask Rest API

22 messages · Page 1 of 1 (latest)

abstract rampart
#

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)

river egretBOT
#

Project ID: 4cc29972-e583-4641-81d0-26868fcc02e7

opaque sigilBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

abstract rampart
#

4cc29972-e583-4641-81d0-26868fcc02e7

warped fog
#

we are going to need more information than "the server doesn't work"

abstract rampart
#

The error I provided is all that is shown in my logs

warped fog
#

are you using gunicorn when on railway?

abstract rampart
#

yeah:
web: gunicorn main:app

warped fog
#

have you confirmed it's working locally when starting your app with that command?

abstract rampart
#

Just tested it, it doesn't appear to work, so im guessing its an issue on my side

warped fog
#

does gunicorn even natively support websockets? maybe you want to use Daphne instead?

abstract rampart
#

I'll check right now

warped fog
#

I think the start command for Daphne would be

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

urban gyro
warped fog
#

well the things ive already said would apply to you, so give daphne a try

abstract rampart
#

This is the command:
web: gunicorn --worker-class eventlet -w 1 main:app

robust pulsar
#

Will we be able to use both HTTP and TCP traffic?

warped fog
#

since when did gunicorn without geventlet support tcp??

abstract rampart