Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status 502: [WARNING] Invalid HTTP request received. #680

Closed
gautamsinghania95 opened this issue Nov 5, 2019 · 11 comments
Closed

Status 502: [WARNING] Invalid HTTP request received. #680

gautamsinghania95 opened this issue Nov 5, 2019 · 11 comments

Comments

@gautamsinghania95
Copy link

I was trying to build a typeahead search API. This API gets called in quick succession, and I am getting an intermittent 502 response.

To Reproduce
Not sure how to reproduce this, as normal API calls, when spaced out, are working fine.

Expected behavior - Logs

2019-11-05T06:17:55.447961016Z [2019-11-05 06:17:55 +0000] [16] [INFO] ('100.96.0.56', 50964) - "POST <<URL_NAME>> HTTP/1.1" 200

Noted Intermittent Behaviour - Logs

2019-11-05T06:17:56.459601437Z [2019-11-05 06:17:56 +0000] [16] [WARNING] Invalid HTTP request received.

Environment:

  • OS: Debian GNU/Linux 10 (buster)
  • FastAPI Version : 0.38.1
  • Python version: 3.6
  • Server: Gunicorn with 2 Uvicorn workers (see config file below)
bind = "0.0.0.0:4000"
workers = 2
worker_class = "uvicorn.workers.UvicornWorker"
timeout = 300

Additional context

  • Added timeout in config after searching on the internet, did not work
@gautamsinghania95 gautamsinghania95 added the bug Something isn't working label Nov 5, 2019
@euri10
Copy link
Contributor

euri10 commented Nov 5, 2019 via email

@gautamsinghania95
Copy link
Author

Hi!!

This is an issue with the deployed version of the app. I have tried to reproduce the problem in my local environment, but to no effect.

Please see if you can help in some other fashion.

Thanks!
Gautam

@gautamsinghania95
Copy link
Author

Hi,

Closing the issue as it was resolved from my end.

Resolution: The deployment platform only accepted HTTP 1.1 calls, but the uvicorn worker class I was using uvicorn.workers.UvicornWorker was sending both types of request. Replacing it with uvicorn.workers.UvicornH11Worker resolved it.

Thanks.

@euri10
Copy link
Contributor

euri10 commented Nov 6, 2019

glad you solved it, for reference which plateform is it and by both types of request you mean 1.0 and 1.1 calls ?

@tiangolo
Copy link
Owner

Thanks for the help here @euri10 ! 👏 🙇

Thanks for reporting back and closing the issue @gautamsinghania95 👍

@sacharbit
Copy link

sacharbit commented Apr 29, 2020

@gautamsinghania95 sorry but can you give more information on how to do that? I have the same issue as you and can't seem to find how to change uvicorn.workers.UvicornWorker

Thanks in advance

edit: nevermind, I found it
it's the http parameter that you put as "h11"

@ssafty
Copy link

ssafty commented Apr 29, 2020

According to tiangolo/uvicorn-gunicorn-docker#38, you can set it as an environment variable now WORKER_CLASS="uvicorn.workers.UvicornH11Worker"

@RPGillespie6
Copy link

I had this issue as well, the issue was that I was trying to access with HTTPS instead of HTTP.

@paulinechi
Copy link

I had this issue as well, the issue was that I was trying to access with HTTPS instead of HTTP.

Hi, I'm getting the same error, could you explain how you solved it? I used Caddy which auto issues https :/

@hadpro24
Copy link

This not work for me, have you found any other solutions guys?

According to tiangolo/uvicorn-gunicorn-docker#38, you can set it as an environment variable now WORKER_CLASS="uvicorn.workers.UvicornH11Worker"

@tiangolo tiangolo added question Question or problem answered reviewed and removed bug Something isn't working labels Feb 22, 2023
@tiangolo tiangolo reopened this Feb 28, 2023
@github-actions
Copy link
Contributor

Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs.

@tiangolo tiangolo reopened this Feb 28, 2023
Repository owner locked and limited conversation to collaborators Feb 28, 2023
@tiangolo tiangolo converted this issue into discussion #7983 Feb 28, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

8 participants