Nginx App Interface Connection timed out

Source: Internet
Author: User

Intranet has an app server, the interface is published through Nginx. Mobile phone via wireless login app, sometimes prompt connection timeout.

Wireless routers and app servers are connected via an intranet switch. Should not time out ah, it may be a router problem.

Then changed several routers, MI Mini, Asus Rt-ac87u,tp-link wvr1750g

Consulting vendors, testing a bit, when time-out, access to Baidu video what is normal. There is no problem with the router, possibly a server problem. Because the server is a PC host, the configuration is poor, and later replaced by Dell R620, or the same problem.

Because the company around 30 wireless, 2.4G transmission speed is 450M, may be a wireless interference problem.

Finally bought a Nighthawk X6 r8000,2.4g transmission speed is 600M, found or there is a timeout.

On-line search data nginx timeout problem, optimized some parameters, found that there is still a timeout.


Phone installation (ping & DNS) software, version 2.3, continuous test dts.xx.com with TCP ping,

About 1-2 minutes, prompting connection timed out, the timeout will last for one minute. When a timeout occurs, the phone logs on to the app, prompting the connection to timeout.


Then time out when the server catches the packet

[Email protected] ~]#tcpdump-i eth0-s0-w a.cap

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/B2/wKioL1WDfjPw4qxQAAGMLHi9UR8507.jpg "title=" Viewfile.png "alt=" Wkiol1wdfjpw4qxqaagmlhi9ur8507.jpg "/>

Discovered that the wireless router sent a SYN request packet to the server, but did not get a response from the server.

A TCP retransmission (TCP packet retransmission) occurs

Because the server has tcp_tw_recycle enabled (in order to support high concurrency)

TCP Request Recycling, if this is the case, then the same IP packet in the default 60s will be recycled.

The time of the network packet is certainly less than this request time, then the server will think he is invalid connection, will reject the connection, so the TCP packet retransmission occurs.

That's why the above phenomenon occurs and the timeout lasts for one minute.

And then I turned the tcp_tw_recycle off.

Vi/etc/sysctl.conf

Set to 0, which means close

Net.ipv4.tcp_tw_reuse = 0

net.ipv4.tcp_tw_recycle = 0

Load configuration

[Email protected] ~]#sysctl-p

Finally again with the TCP ping test, test for 20 minutes, no connection timeout occurred.

The app refreshes the data, and no timeouts occur.


Well, to solve this problem, before all rely on the blind guess. There is no layer of analysis to analyze the problem, it took such a long time to get it done.

The router only provides data forwarding, and as long as it is forwarded, its task is completed.

Should be a server problem and then grab the packet, why did the server not respond?

Why does TCP retransmission (TCP packet retransmission) occur?

So the problem is getting closer to the truth and it's settled, just like Sherlock Holmes.


Later found that the system log appears

June 11:13:45 127.0.0.1tcp:time wait bucket table overflow

That would only increase the value of net.ipv4.tcp_max_tw_buckets.

Net.ipv4.tcp_max_tw_buckets = 100000

Load configuration

[Email protected] ~]#sysctl-p

See again, there is no more.

This article is from the "Falling Star" blog, make sure to keep this source http://xiao987334176.blog.51cto.com/2202382/1663462

Nginx App Interface Connection timed out

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.