spring cloud gateway客户端websocket断开连接,服务侧连接没有关闭的问题处理

之前在单体架构项目中使用了websocket主动推送消息的功能,后来改成了微服务架构,结果发现部分消息丢失,没能推送给客户端;深入排查发现服务端无法感知websocket连接状态,但是在单体架构里面是没这个问题的,后来发现是网关在处理客户端主动断开的情况时发生了异常。

查阅资料发现是spring gatewaybug,并且相关issue2023年4月已经关闭,于是根据时间节点,找到了4月之后的一个版本(3.1.8)的spring-cloud-gateway-server替换了原来的依赖,重新打包测试发现问题解决,特此记录。

个人使用的spring cloud alibaba 2021.0.6.0版本,对应Spring Cloud 2021.0.5版本。

关键pom修改如下:

xml 复制代码
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
    <!-- 排除旧版本 -->
    <exclusions>
        <exclusion>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-gateway-server</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<!-- 引入新版本 -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-gateway-server</artifactId>
    <version>3.1.8</version>
</dependency>

多说一句:

软件是在不断的迭代优化的,如果条件允许尽量跟上稳定发布版本。

相关推荐
爱吃土豆的马铃薯ㅤㅤㅤㅤㅤㅤㅤㅤㅤ2 小时前
如何使用Java WebSocket API实现客户端和服务器端的通信?
java·开发语言·websocket
亲爱的非洲野猪9 小时前
Spring Cloud Gateway介绍 - -基础概念,简单工作原理和配置示例
java·spring boot·gateway
麦兜*18 小时前
Spring Boot 集成Reactive Web 性能优化全栈技术方案,包含底层原理、压测方法论、参数调优
java·前端·spring boot·spring·spring cloud·性能优化·maven
洁辉2 天前
Spring Cloud 全栈指南:构建云原生微服务的终极武器
spring cloud·微服务·云原生
roc_lab2 天前
Spring Cloud Feign默认不支持重定向解决方案
spring cloud
重生之后端学习2 天前
day08-Elasticsearch
后端·elasticsearch·spring cloud·中间件·全文检索·jenkins
也许明天y2 天前
Spring Cloud Gateway 自定义分布式限流
redis·后端·spring cloud
你喜欢喝可乐吗?2 天前
RuoYi-Cloud ruoyi-gateway 网关模块
java·spring cloud·gateway
你喜欢喝可乐吗?2 天前
RuoYi-Cloud 验证码处理流程
java·spring cloud·微服务·vue
麦兜*2 天前
Spring Boot秒级冷启动方案:阿里云FC落地实战(含成本对比)
java·spring boot·后端·spring·spring cloud·系统架构·maven