Uvicorn Health Check Fails with IPv6 Bind

2 years ago

Getting really confused, I switched from Hypercorn to Uvicorn for alleged performance reasons, and while it binds just find to IPv6 and IPv4 locally, as well as IPv4 on Railway (the healthcheck succeeds), IPv6 just refuses to be bound.

Closed

16 Replies

2 years ago

daea8913-00d4-474d-b3d8-2bfc2bfbbcf0


2 years ago

        run(
            "linkpulse.app:app",
            reload=is_development,
            host="0.0.0.0" if is_development else "::",
            port=int(os.getenv("PORT", "8000")),
            log_config={
                "version": 1,
                "disable_existing_loggers": False,
                "loggers": {
                    "uvicorn": {"propagate": True},
                    "uvicorn.access": {"propagate": True},
                },
            },
        )

2 years ago

Yeah, the double JSON logging is weird, but I have different problems right now.

The app binds fine to IPv6, it just won't clear the healthcheck. Although, I don't think Caddy resolved either... :/

1302073064275709952


2 years ago

1302073171268210731


2 years ago

The latest project deploy is bound to 0.0.0.0 and it works fine; but of course we need Private Networking (which worked wonderfully with Hypercorn).

We use the Caddy proxy over Private Networking, which as we know does not support IPv4 networking.


2 years ago

With hypercorn, we invoked it via

  "deploy": {
    "startCommand": "hypercorn linkpulse.app:app --bind \"[::]:$PORT\""
  }
}

2 years ago

Now we do json "deploy": { "startCommand": "python3 -m linkpulse serve" } and uvicorn.run is invoked internally.


2 years ago

Yeah, confirmed, the IPv6 bind will run fine, but neither the healthcheck or Caddy instance can connect to it. Testing locally, doesn't seem like anything should be going wrong.

1302075549832712222


2 years ago

Okay, I restored a temporary hotfix that uses hypercorn like this: ```json

"deploy": {

"startCommand": "hypercorn linkpulse.app:app --bind "[::]:$PORT" --log-config "toml:logging.toml""

}



2 years ago

I dunno, I guess I'm kinda shooting myself in the foot here by admitting that, because I doubt Railway staff are particularly interested in figuring out why one of two available compatible ASGI workers are just not working.


2 years ago

I've had uvicorn binding to IPv6 working with health checks when I did my test suite for the new runtime


2 years ago

Any details about what might differ between our setups?


2 years ago

not this moment, I'd have to re-roll a python app with uvicorn and what happens


2 years ago

Really not looking good, I tried using the uvicorn variant: uvicorn \"linkpulse.app:app\" --host :: --port $PORT, but no dice. Healthcheck still fails, Caddy doesn't connect.


2 years ago

I'll check it out when I'm back at my computer later


2 years ago

went back to look at what i had previously tested, i used gunicorn with a uvicorn worker -

gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b [::]:$PORT main:app

Welcome!

Sign in to your Railway account to join the conversation.

Loading...