An action was executed twice. This operation took more than 5 minutes to complete, so I searched for a few places where I can set the timeout. I hope it will be helpful to everyone.
I found it while testing the project today. An action was executed twice. This operation took more than 5 minutes to complete. The engineering environment was apache2+tomcat6.0.
Online search found several places where timeout can be set:
1.ajax syntax to set the unit milliseconds, for example:
$.ajax({ url: XXX, timeout: 600000, type: 'POST', data: { }, error: function() { show_fail_meg("启动系统失败 !"); } });
2.tomcat configuration server.xml in milliseconds
Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
3.apache configuration file httpd.conf in seconds
# # Timeout: The number of seconds before receives and sends time out. # Timeout 60
After modifying the above several places, it was found that it still did not take effect. Finally, it was located in the mod_jk module.
mod_jk, referred to as JK, is the Apache server A pluggable module that provides Apache or IIS servers with the ability to process JSP/Servlets.
That is to say, the settings of JK may cover the settings of apache2, tomcat and ajax.
The content of JK’s configuration file/etc/httpd/conf/workers.properties is as follows:
worker.master.socket_timeout=300
Sure enough, I saw that this number is exactly 5 minutes, which is consistent with the abnormal phenomenon. After changing the size and restarting, it is normal!
The above is all the content of this article, I hope it will be helpful to everyone!
Related recommendations:
20 classic AJAX interview questions
The above is the detailed content of How to set ajax timeout (an action is executed twice). For more information, please follow other related articles on the PHP Chinese website!