Uvicorn Health Check Fails with IPv6 Bind

7 months 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.

0 Replies

7 months ago

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


7 months 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},
                },
            },
        )

7 months 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… :/

1302073064275710000


7 months ago

1302073171268210700


7 months 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.


7 months ago

With hypercorn, we invoked it via

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

7 months ago

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


7 months 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.

1302075549832712200


7 months 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\"" } And it does work just fine.


7 months 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.


7 months ago

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


7 months ago

Any details about what might differ between our setups?


7 months ago

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


7 months ago

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


7 months ago

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


7 months 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