python - Nginx-ajax-django:页面上出现 504 超时错误,错误日志:上游超时(110:连接超时),TTFB>1
问题描述
我有一个在 nginx 服务器上运行的 django 应用程序,它使用 ajax 对 html 页面进行异步渲染。我收到 504 网关超时错误。我几乎尝试了堆栈溢出中提到的所有解决方案,但没有任何结果。在我的应用程序中,我上传了一个 Excel 表格,从中解析、处理、推送到数据库中的数据,然后在 html 页面上显示处理状态。我意识到前两到三行数据正在正常处理,结果也正在正确显示。对于剩余的行,后端进程正在正确发生,但 ajax 没有从 django 视图接收状态消息。它显示 504 错误消息。错误日志显示上游超时错误。我什至包含timeout:333333
在我的 ajax 代码中。如果我做async:false
在 ajax 中,进程变慢,我收到页面无响应错误消息。通过仔细观察,我意识到对于不完整的流程,TTFB 正在变得超过 1。那么有人可以解释该怎么做吗?
nginx.conf
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush off;
tcp_nodelay on;
keepalive_timeout 605;
types_hash_max_size 2048;
# server_tokens off;
# proxy_set_header Host $host;
proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
proxy_set_header Connection "";
proxy_connect_timeout 605;
proxy_send_timeout 605;
proxy_read_timeout 605;
send_timeout 605;
fastcgi_read_timeout 605;
client_header_timeout 605;
client_body_timeout 605;
proxy_buffering off;
proxy_request_buffering off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include fastcgi_params;
include /etc/nginx/mime.types;
default_type application/octet-stream;
}
解决方案
推荐阅读
- flutter - 配置 Flutter 进行 Web 开发时,“连接的设备”上不会出现“Web 服务器”
- flutter - 无法从 Firestore Flutter 中检索数据
- google-bigquery - 从 Google Ads 到 BigQuery 的转移服务问题
- dotcms - 谁能确定这段代码是什么语言?
- javascript - 在 HTML 中使用 js 文件作为 cdn
- python - 用不等式 astropy 混合建模约束参数
- android-studio - Android Studio 多平台项目的 commonMain 中的 ktor 依赖项在 IDE 中未解决,但代码运行
- flutter - 我正在寻找类似颤动的导航栏,如果你知道,请指导我
- python-venv - 使用整个 venv 复制文件夹后的 pip 列表
- html - 未显示所选选项(角度,html)