流式对话接口已经返回message_end类型数据,但是接口流没有关闭结束。
根据网上.解决方法:
1.nginx配置缓存区设置;
2.nginx的临时目录修改权限、
以上方法均无效。
最终解决方法:
nginx.conf配置以下代码
proxy_buffering off; # 禁用代理缓冲
proxy_read_timeout 3600s; # 设置上游读取超时时间为 1 小时
proxy_send_timeout 300s;
proxy_connect_timeout 75s;
nginx.conf配置文件
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name xxxxx # 域名;
# 处理 /aiapi/ 的请求
location /aiapi/ {
proxy_pass http://xxx.com/;
proxy_buffering off; # 禁用代理缓冲
proxy_read_timeout 3600s; # 设置上游读取超时时间为 1 小时
proxy_send_timeout 300s;
proxy_connect_timeout 75s;
# 添加 CORS 响应头
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-
Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
# 处理 OPTIONS 预检请求
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
}
# 处理根路径的请求
location / {
root /var/www/oachat/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
expires 60s;
}
ssl_certificate "/etc/nginx/cert/shmh.gov.cn-cert-chain.pem";
ssl_certificate_key "/etc/nginx/cert/shmh.gov.cn.key";
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers on;
}
error_log /etc/nginx/conf.d/error.log warn; # 全局错误日志
10万+

被折叠的 条评论
为什么被折叠?



