When uwsgi is deployed to nginx, invalid request block size: 4161 (max 4096) appears)

Source: Internet
Author: User
Tags openid

 

After using Flask to create a web platform, log on to openid and deploy it on nginx using the uwsgi service. There is no problem in running, but the error 502 occurs occasionally during login, generally, after successful login, no subsequent operations will go wrong.

After viewing the uwsgi log, it is found that the following error occurs:

Invalid request block size: 4161 (max 4096)... skip

Cause: by default, uwsgi allocates a small buffer (4 k) to receive the header information of each request. If "invalid request block size" is displayed in the log ", it means you need a larger buffer.


The problem is that the url address contains more than 4096 characters, and 4096 is the default value of buffer-size in uwsgi configuration. Therefore, you only need to increase the buffer-size.

I use uwsgi-x to specify the uwsgi configuration file to start the server. Therefore, you only need to modify it to the following method:

Uwsgi-x platform. uwsgi. xml -- buffer-size 32768

To modify the parameters, run the following command for uwsgi:

View the CODE piece derived from my CODE piece on CODE

Uwsgi-B 8192

You can also modify the uwsgi startup configuration file, such as uwsgi. ini, to add the following configuration:

View the CODE piece derived from my CODE piece on CODE
Buffer-size = 8192


The problem is basically solved. Why does this problem happen occasionally? This is because the openid will carry a parameter named next_url during login, which is used to specify the address to return after successful login. If this next_url is too long, it will cause the url address to exceed 4096, sometimes next_url =/, that is, the root address of the website, the url length will not exceed 4096. It is also related to the length of login information returned by openid. As a result, some people will never see this error, and some may occasionally encounter this problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.