HTTPSMiddleware not responding for HTTP [_ProactorBasePipeTransport._call_connection_lost(None)] #2428
Unanswered
drcdr
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to get https redirect working with FastAPI (and loosely following the approach here). I have narrowed my problem down to a Starlette-only configuration.
I'm using conda and Windows 10. I created a new environment:
This results in uvicorn 0.26.0 and starlette 0.35.1.
My example:
I run as
python test_starlette.py
Using
https://127.0.0.1/get_message
works as expected.When I try
http://127.0.0.1:80/get_message
, I get a 404 error:No webpage was found for the web address: http://127.0.0.1/get_message
When I try
http://127.0.0.1/get_message
, I get an ERR_EMPTY_RESPONSE on the page, and this error in the logs:I've tried several different things, all of which give similar results as above
https://127.0.0.1:8060/get_message
works,http://127.0.0.1:8060/get_message
doesn't, same ERR_EMPTY_RESPONSE and crash)Middleware(CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"] ),
both before and afterHTTPSRedirectMiddleware
WSL2: I've tried everything above in WSL2 as well, modifying the port from 443 to 8000 so I don't have to run as root. I don't get the asyncio trace error, but I also don't get the http redirect to work (still ERR_EMPTY_RESPONSE on http, port 8000).
I'm not exactly sure how this redirect is supposed to work (from reading discussions at starlette, and various web posts), as far as scheme and port substitution, so I'm posting here before posting a bug. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions