Technology Sharing

How to fix the problem that the spring cloud gateway client websocket is disconnected but the server side connection is not closed

2024-07-11

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

Previously, the websocket active message push function was used in a monolithic architecture project, but later it was changed to a microservice architecture. As a result, it was found that some messages were lost and could not be pushed to the client. After in-depth investigation, it was found that the server could not perceive the websocket connection status, but there was no such problem in the monolithic architecture. Later, it was discovered that an exception occurred when the gateway handled the situation where the client actively disconnected.

After checking the data, I found thatspring gatewayofbug, and relatedissueexist2023年4月It has been closed, so according to the time node, I found a version after April (3.1.8)ofspring-cloud-gateway-serverI replaced the original dependency, repackaged and tested it and found that the problem was solved. I would like to record it here.

Personal usespring cloud alibaba 2021.0.6.0Version, correspondingSpring Cloud 2021.0.5Version.

The key pom modifications are as follows: