Uvicorn Health Check Fails with IPv6 Bind

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.
Solution:
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
gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b [::]:$PORT main:app
...
Jump to solution
13 Replies
Percy
Percy3w ago
Project ID: daea8913-00d4-474d-b3d8-2bfc2bfbbcf0
Xevion
XevionOP3w ago
daea8913-00d4-474d-b3d8-2bfc2bfbbcf0
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},
},
},
)
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},
},
},
)
Xevion
XevionOP3w 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... :/
No description
Xevion
XevionOP3w ago
No description
Xevion
XevionOP3w 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. With hypercorn, we invoked it via
"deploy": {
"startCommand": "hypercorn linkpulse.app:app --bind \"[::]:$PORT\""
}
}
"deploy": {
"startCommand": "hypercorn linkpulse.app:app --bind \"[::]:$PORT\""
}
}
Now we do
"deploy": {
"startCommand": "python3 -m linkpulse serve"
}
"deploy": {
"startCommand": "python3 -m linkpulse serve"
}
and uvicorn.run is invoked internally.
Xevion
XevionOP3w 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.
No description
Xevion
XevionOP3w ago
Okay, I restored a temporary hotfix that uses hypercorn like this:
"deploy": {
"startCommand": "hypercorn linkpulse.app:app --bind \"[::]:$PORT\" --log-config \"toml:logging.toml\""
}
"deploy": {
"startCommand": "hypercorn linkpulse.app:app --bind \"[::]:$PORT\" --log-config \"toml:logging.toml\""
}
And it does work just fine. 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.
Brody
Brody3w ago
I've had uvicorn binding to IPv6 working with health checks when I did my test suite for the new runtime
Xevion
XevionOP3w ago
Any details about what might differ between our setups?
Brody
Brody3w ago
not this moment, I'd have to re-roll a python app with uvicorn and what happens
Xevion
XevionOP3w 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.
Brody
Brody3w ago
I'll check it out when I'm back at my computer later
Solution
Brody
Brody3w 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
gunicorn -w 4 -k uvicorn.workers.UvicornWorker -b [::]:$PORT main:app
Want results from more Discord servers?
Add your server