Issue with multiple users accessing my Flet Web App

amgartendevTRIAL

2 months ago

I'm developing a web application using Flet and Python, and I'm hosting it on Railway. My goal is to have a single instance of my app running, allowing multiple users to connect without issues, just like a normal web app.

However, I'm encountering a problem:
- When I run my app locally using (basically running the app and binding the port 8000):
flet run .\main.py -w -p 8000
It works fine

- But if I try to start another instance on the same port, I get this error:
ERROR: [Errno 10048] error while attempting to bind on address ('::', 8000, 0, 0): [WinError 10048] only one usage of each socket address (protocol/network address/port) is normally permitted

- Also, when deployed on Railway, it seems like every new user request tries to bind the port again, which shouldn't happen.

What I'm trying to achieve:
- I want my app ro run as a single instance where multiple users can cnnect, just like any website
- Each user should have their own session without interfering with others

My current code (simplified)
```import flet as ft
import os

def main(page: ft.Page):
page.title = "My Flet App"
page.add(ft.Text("Hello, world!"))

PORT = int(os.environ.get("PORT", 8000)) # Use Railway's assigned port

ft.app(target=main, port=PORT, view=ft.WEB_BROWSER) # Start server```

Useful Link
I've been searching for a while and found this in Railway's documentation:
"Note: If your application needs to be accessible over both public and private networks, your application server must support dual stack binding. Most servers handle this automatically when listening on ::, but some, like Uvicorn, do not."

link to this doc: https://docs.railway.com/guides/public-networking

Can someone help me?

0 Replies

amgartendevTRIAL

2 months ago

826548a8-d043-48d4-9bf2-b274d50f9a26


2 months ago

how are you running the flet app while on Railway


amgartendevTRIAL

2 months ago

cd client && python main.py


amgartendevTRIAL

2 months ago

but i've already tried cd client && flet run [main.py](main.py) -w


2 months ago

please provide errors


amgartendevTRIAL

2 months ago

ERROR: [Errno 10048] error while attempting to bind on address ('0.0.0.0', 48901): [winerror 10048] only one usage of each socket address (protocol/network address/port) is normally permitted


amgartendevTRIAL

2 months ago

I think the problem is how I'm rendering the components of my app, but i works fine locally


amgartendevTRIAL

2 months ago

idk


2 months ago

is this an isolated or shared monorepo?


amgartendevTRIAL

2 months ago

it is a shared monorepo


2 months ago

what is your current start command


amgartendevTRIAL

2 months ago

For the Server it is cd server && python [main.py](main.py)
For the Client it is cd client && python [main.py](main.py)

1344404130705309700


2 months ago

neither have deploys?


amgartendevTRIAL

2 months ago

I just shutted it down so I don't waste my $5 free trial… Times are tough man 😅 Just kidding, it was deployed so I could test the platform and pay for a plan


amgartendevTRIAL

2 months ago

But it returned the error above