关于websocket接口WebSocket is closed before the connection is established.

7,225 阅读1分钟

问题:webpack接口报错WebSocket is closed before the connection is established. 1658744337185.png 2.png 解决

1.排查后端接口-通过复制websocket接口,在线上测试后端接口是否可以正常返回--测试结果,后端可以正常返回

image.png

2.开始排查前端代码---一调用websocket方法,直接跳到关闭的方法中调用

image.png

3.正确的写法如下

image.png

为自己的愚蠢浪费一下午的时间