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的通信路径加入白名单即可。

相关推荐
chilavert3181 天前
技术演进中的开发沉思-302计算机原理:网络基础
网络·计算机原理
Hellc0071 天前
Docker网络冲突排查与解决方案:完整指南
网络·docker·容器
眠りたいです1 天前
Docker核心技术和实现原理第二部分:docker镜像与网络原理
运维·网络·docker·容器
闲人编程1 天前
消息通知系统实现:构建高可用、可扩展的企业级通知服务
java·服务器·网络·python·消息队列·异步处理·分发器
Xの哲學1 天前
Linux Platform驱动深度剖析: 从设计思想到实战解析
linux·服务器·网络·算法·边缘计算
ikkkkkkkl1 天前
计算机网络:物理层
网络·计算机网络·物理层
镜中人★1 天前
408计算机组成原理考纲知识点
网络·笔记
汤愈韬1 天前
双向NAT
网络·网络协议·网络安全·security·huawei
*才华有限公司*1 天前
RTSP视频流播放系统
java·git·websocket·网络协议·信息与通信
栗子叶1 天前
IP协议 地址划分&MAC地址作用&ip addr命令
网络·tcp/ip·macos