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>

多说一句:

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

相关推荐
野蛮人6号12 小时前
黑马天机学堂Day01-08.搭建项目环境-本地开发部署方式——不知道nacos的密码是什么
java·spring cloud·黑马程序员·天机学堂·黑马天机学堂
乱七八糟的屋子12 小时前
Poco C++高级实战教程:线程池+日志系统+加密算法+WebSocket长连接
c++·websocket·加密解密·#poco·#c++高级开发
dyonggan15 小时前
IDEA从零搭建SpringCloud Alibaba完整工程
java·spring cloud·intellij-idea
tryxr1 天前
Spring Cloud Gateway
java·开发语言·数据库·网关·spring cloud·gateway
码农学院1 天前
建筑机械行业AI搜索优化技术方案:基于Spring Cloud微服务架构的文件管理与智能化内容推荐系统
人工智能·spring cloud·架构
Devin~Y1 天前
互联网大厂Java面试实战:Spring Boot、MyBatis、Redis、Kafka、JWT、Spring Cloud 与 AI 场景追问
java·spring boot·redis·spring cloud·kafka·mybatis·spring security
Jay Kay2 天前
SGLang Model Gateway 特性详解(Cache-Aware 之外)
gateway·sglang
_waylau2 天前
Spring Framework HTTP服务客户端详解
java·后端·网络协议·spring·http·spring cloud
tryxr2 天前
Spring Cloud eureka
spring·spring cloud·eureka
宠友信息2 天前
MySQL复合索引与Druid优化仿小红书源码个人主页查询链路
数据库·spring boot·websocket·mysql·uni-app