websocket client无法连接到websocket server 的问题

1. 问题描述

生产环境的websocket client和server无法通信

2. 日志现象

通过查看日志和问题复现,定位到是client连接到server失败,导致无法通信。

出现问题的代码

出现问题的日志

21:25:27.790 [main] INFO websocket.MyWebSocketClient - start to connect... 21:25:30.943 [pool-1-thread-1] INFO websocket.MyWebSocketClient - The HTTP response from the server [200] did not permit the HTTP upgrade to WebSocket 21:26:00.823 [pool-1-thread-1] INFO websocket.MyWebSocketClient - The HTTP response from the server [200] did not permit the HTTP upgrade to WebSocket

该日志是catch异常后打印出来的。

3.分析过程

通过上面的代码我日志,知道是连接失败,但是从日志来看,以为是成功连接了,只是http和websocket的版本差异导致的,一直在分析。知直到费了大量的时间排查对比代码,才发现是服务端的SpringSecurity拦截了,导致客户端无法连接。

4. 修改方案

只需要将websocket的通信路径加入白名单即可。

相关推荐
轨迹H23 分钟前
【春秋云镜】CVE-2023-2130漏洞复现exp
网络协议·网络安全·渗透测试·ctf·cve
wu~9701 小时前
计算机网络自定向下:第二章复习
服务器·网络·架构
Mylvzi1 小时前
Linux 性能利器:详解 `top` 命令的使用与输出信息解析
linux·服务器·网络
等风来不如迎风去2 小时前
【samba】umount:**** target is busy. ubuntu24.04 卸载挂载点
网络协议·远程桌面·nomachine
Dream Algorithm3 小时前
中国移动6周年!
网络·架构·信息与通信
菜鸟康3 小时前
C++实现分布式网络通信框架RPC(2)——rpc发布端
分布式·网络协议·rpc
摸鱼仙人~4 小时前
UDP与TCP通信协议技术解析
网络协议·tcp/ip·udp
小疆智控4 小时前
农田水利如何「聪明」起来?Modbus转Ethernet IP破解设备互联
网络·网络协议·tcp/ip
木mu升4 小时前
java 局域网 rtsp 取流 WebSocket 推送到前端显示 低延迟
网络·websocket·网络协议