简体   繁体   English

Cloudflare HTTP POST 524带有node.js + express的超时

[英]Cloudflare HTTP POST 524 Timeout with node.js + express

I am having a trouble using HTTP POST when cloudflare is enabled. 启用cloudflare时,我在使用HTTP POST时遇到问题。 It keeps returning 524 timeout. 它一直返回524超时。

Failed to load resource: the server responded with a status of 524 (Origin Time-out) 

But when I disabled cloudflare, the HTTP POST works fine. 但是当我禁用cloudflare时,HTTP POST工作正常。

Any idea what might caused this? 知道是什么原因引起的吗?

UPDATE UPDATE

I am using AJAX POST, does this got anything to do with ajax? 我正在使用AJAX POST,这与ajax有什么关系吗?

Thanks. 谢谢。

General causes for a CloudFlare 524 error . CloudFlare 524错误的一般原因。

Support should be able to provide more detailed troubleshooting. 支持应该能够提供更详细的故障排除。

Console utility "netstat" shows that some connections from CloudFlare are in CLOSE_WAIT state. 控制台实用程序“netstat”显示来自CloudFlare的某些连接处于CLOSE_WAIT状态。 Pointing that server just sits without correctly closing connections. 指出服务器只是没有正确关闭连接。 Looking to the TCP traffic of my web server with Message Analyzer, I found several connections that was established and http request was sent but that wasn't ever processed by my server. 通过Message Analyzer查看我的Web服务器的TCP流量,我发现已建立了几个连接并发送了http请求,但我的服务器从未处理过。

So we get an answer: the number of simultaneously established connections outnumbered available Accept() calls. 所以我们得到一个答案:同时建立的连接数超过可用的Accept()调用数。 So TCP stack connects and wait while application will handle it's connection. 因此,TCP堆栈连接并等待,而应用程序将处理它的连接。 Depending on the situation this can never happen, so the client side just drops this connection after a 30 sec timeout without getting any response. 根据情况,这种情况永远不会发生,因此客户端只需在30秒超时后断开此连接,而不会得到任何响应。

To fix this, you must increase the number of outstanding possible accepts . 要解决此问题,您必须增加可能的未完成接受次数 This parameter can be named as "Max simultaneous connections number" or something similar. 此参数可以命名为“最大同时连接数”或类似名称。 Check your web server documentation \\ ask the support to find it out. 检查您的Web服务器文档\\请求支持人员找到它。

Also, as an experiment, you can force your server to reply with the "Connection:close" header to each request. 此外,作为实验,您可以强制服务器使用“Connection:close”标头回复每个请求。 This may prevent reaching the active connections limit problem because CloudFlare keep-alive them just way too long. 这可能会阻止达到活动连接限制问题,因为CloudFlare保持活动时间太长。

Also, the more simultaneous requests you do, the more probability to get in troubles. 此外,您同时执行的请求越多,遇到麻烦的可能性就越大。 You can try to set some small webserver-side timeout for idle connections. 您可以尝试为空闲连接设置一些小的Web服务器端超时

PS: Illustration of CloudFlare's connections number after one client loaded a page: ( http://i.imgur.com/IgwGLCf.png ) PS:一个客户端加载页面后CloudFlare连接数的插图:( http://i.imgur.com/IgwGLCf.png

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM