uwsgi invalid request block size

2019-01-21 01:11发布

I'm running uwsgi in emperor mode

uwsgi --emperor /path/to/vassals/ --buffer-size=32768

and getting this error

invalid request block size: 21327 (max 4096)...skip

What to do?? I also tried -b 32768

标签: uwsgi
5条回答
唯我独甜
2楼-- · 2019-01-21 01:34

I aslo ran into same issue while following some tutorial. The problem was that I set the option socket = 0.0.0.0:8000 instead of http = 0.0.0.0:8000. socket option intended to be used with some third-party router (nginx for instance), while when http option is set uwsgi can accept incoming HTTP requests and route them by itself.

查看更多
女痞
3楼-- · 2019-01-21 01:45

I ran into the same issue trying to run it under nginx and was following the docs here. It is important to note that once you switch to nginx you have to make sure you are not trying to access the app on the port specified by the --socket param but rather the "listen" port in nginx.conf. Although your problem is described differently the title matches exactly the issue I had.

查看更多
做自己的国王
4楼-- · 2019-01-21 01:51

I could fix it adding --protocol=http to the uwsgi

查看更多
霸刀☆藐视天下
5楼-- · 2019-01-21 01:53

This error is shown when uWSGI server is using uwsgi protocol and one tries to access it via http protocol by curl or web browser directly. If you can, try configuring your uWSGI server to use http protocol, so you can access it via web browser or curl.

In case you cannot (or do not want to) change it, you can use a reverse proxy (e.g. nginx) in front of local or remote uWSGI server, see http://uwsgi-docs.readthedocs.org/en/latest/Nginx.html

If it feels like too much work, give a try to uwsgi-tools python package:

$ pip install uwsgi-tools

$ uwsgi_curl 10.0.0.1:3030

There is also a simple reverse proxy server uwsgi_proxy if you need to access your application(s) via web browser etc. See more expanded answer https://stackoverflow.com/a/32893520/179581

查看更多
疯言疯语
6楼-- · 2019-01-21 01:54

The correct solution is not to switch to HTTP protocol. You just need to increase the buffer size in uWSGI settings.

buffer-size=32768

or in commandline mode:

-b 32768

Quote from official documentation:

By default uWSGI allocates a very small buffer (4096 bytes) for the headers of each request. If you start receiving “invalid request block size” in your logs, it could mean you need a bigger buffer. Increase it (up to 65535) with the buffer-size option.

If you receive ‘21573’ as the request block size in your logs, it could mean you are using the HTTP protocol to speak with an instance speaking the uwsgi protocol. Don’t do this.

From here: https://uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html

查看更多
登录 后发表回答