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

Spring Boot WebSocket无CONNECTED帧及inboundChannel堆积咨询

Spring Boot WebSocket Broker CONNECT帧无响应故障

故障表现

  • 生产环境Spring Boot服务端WebSocket Broker收到客户端发送的CONNECT帧后,未返回对应的CONNECTED帧
  • 故障初期为偶发,后续逐步恶化,最终浏览器侧发起的所有CONNECT请求均无法收到响应
  • 浏览器控制台日志:
    浏览器控制台日志
  • 服务端控制台日志:
    服务端日志截图

初步排查结论

故障发生时inboundChannel队列存在大量任务积压,是CONNECT帧无响应的直接原因。故障时刻采集的WebSocketMessageBrokerStats日志如下:

2022-06-01 18:22:59,943 INFO  Thread-id-74- springframework.web.socket.config.WebSocketMessageBrokerStats: WebSocketSession[130 current WS(129)-HttpStream(1)-HttpPoll(0), 225 total, 0 closed abnormally (0 connect failure, 0 send limit, 2 transport error)], stompSubProtocol[processed CONNECT(220)-CONNECTED(132)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 2, active threads = 2, queued tasks = 10774, completed tasks = 31806], outboundChannel[pool size = 2, active threads = 0, queued tasks = 0, completed tasks = 570895], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 134, completed tasks = 1985]

从日志可观测到核心异常:inboundChannel线程池核心线程数仅为2,且2个线程全部处于活跃执行状态,队列中排队等待执行的任务数高达10774,处理能力完全跟不上任务提交速度。

核心疑问

哪些业务场景或配置问题会引发inboundChannel队列出现任务排队堆积?

客户端现有STOMP配置(Angular)

const config: StompJS.StompConfig = {
      brokerURL: this.serverUrl,
      connectHeaders: {
        ccid: this.cookieService.get('ccid'),
        username: `${this.globalContext.get('me')['username']}`,
      },
      debug: (str) => {
        this.loggerService.log(this.sessionId, ' | ', str);
      },
      webSocketFactory: () => {
        return new SockJS(this.serverUrl);
      },
      logRawCommunication: true,
      reconnectDelay: 3000,
      heartbeatIncoming: 100,
      heartbeatOutgoing: 100,
      discardWebsocketOnCommFailure: true,
      connectionTimeout: 4000
    };

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.31 22:03:22