亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

HTTPConnectionPool(host='xxxx', port=y):讀取超時。

HTTPConnectionPool(host='xxxx', port=y):讀取超時。

藍山帝景 2022-07-05 17:16:00
在我的 python 腳本中,有多個 API 調用,并且 API 在同一個應用程序中!我正在使用 django 框架!通過 python3 manage.py runserver 它工作正常!但是在帶有 nginx 服務器、主管、gunicorn 的 centos7 虛擬機中,調用第三個 API 后它無法正常工作!出現了這個錯誤:The complete exception is provided below:<class 'requests.exceptions.ReadTimeout'>HTTPConnectionPool(host='x.x.x.x', port=y): Read timed out. (read timeout=None)在 nginx 錯誤日志中只有這個錯誤:[error] 12020#12020: *133 upstream prematurely closed connection while reading response header from upstream, client:需要一些幫助
查看完整描述

1 回答

?
子衿沉夜

TA貢獻1828條經驗 獲得超3個贊

終于我找到了解決辦法!


其實是因為gunicom和nginx的超時。


我的腳本需要 30 多秒,所以請更新我的 gunicorn 配置文件!


這是配置:


[program:project]

command = gunicorn -c /opt/project/gunicorn_config.py project.wsgi -t 300

directory = project directory

user = user

nginx配置也需要添加這個代理設置:


location / {

    proxy_pass http://127.0.0.1:8001;

    proxy_set_header X-Forwarded-Host $server_name;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-Proto $scheme;

    add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';

    proxy_read_timeout 300s;

    proxy_connect_timeout 300s;

}

謝謝!如果有人遇到同樣的問題,希望這會有所幫助!


查看完整回答
反對 回復 2022-07-05
  • 1 回答
  • 0 關注
  • 502 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號