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

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部