You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NGINX代理下Express SSE连接每分钟断开问题排查求助

NGINX代理下Express SSE服务器每分钟断开连接问题诊断

我搭建了一个基于Express的SSE(Server-Sent Events)服务器,部署在NGINX代理之后,但连接每隔一分钟就会断开。以下是详细的curl会话信息:

curl -N -verbose --http2 -H "Accept:text/event-stream" https://umx.safuyi.com/api/rooms/960/events
*   Trying 49.235.227.189:443...
* Connected to umx.safuyi.com (49.235.227.189) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: CN=umx.safuyi.com
*  start date: Jan  5 00:00:00 2023 GMT
*  expire date: Jan  5 23:59:59 2024 GMT
*  subjectAltName: host "umx.safuyi.com" matched cert's "umx.safuyi.com"
*  issuer: C=CN; O=TrustAsia Technologies, Inc.; CN=TrustAsia RSA DV TLS CA G2
*  SSL certificate verify ok.
> GET /api/rooms/960/events HTTP/1.1
> Host: umx.safuyi.com
> User-Agent: curl/7.79.1
> Referer: rbose
> Accept:text/event-stream
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx/1.14.0 (Ubuntu)
< Date: Sun, 29 Jan 2023 12:31:33 GMT
< Content-Type: text/event-stream
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Cache-Control: no-cache
< 
data: [{"who":"0.36735210198439616/2023-01-29T12:30:25.938Z","did":"left room","room":"960"},{"who":"0.6205505230339852/2023-01-29T12:30:23.668Z","did":"left room","room":"960"},{"who":"0.10731778838068662/2023-01-29T12:31:26.900Z","did":"entered room","room":"960"}]

event: clientId
data: {"clientId": "0.9871521861164745/2023-01-29T12:31:33.839Z"}

* transfer closed with outstanding read data remaining
* Closing connection 0

我已在响应中添加以下请求头以禁用NGINX的缓冲功能,但似乎没有效果:

Content-Type: text/event-stream;
Cache-Control: no-cache;
X-Accel-Buffering: no;

内容的提问来源于stack exchange,提问作者branaway

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 21:01:36