做websocket代理,报错failed: Invalid frame header

用http-proxy-middleware做websocket代理,为什么连上之后立刻就中断了,报错failed: Invalid frame header

this.wsUrl = `ws://${location.host}/ctfo-platform-auth/websocket/${ticketId}`
this.ws = new WebSocket(this.wsUrl);
this.ws.onopen = () => {
   console.log("连接已链接...");
};

this.ws.onclose = () => {
   console.log("连接已关闭...");
};

this.ws.onmessage = (res) => {
   console.log("收到服务器内容", res);
};
这个是websocket链接
'/ctfo-platform-auth': {
      target: 'http://***.***.***:****',
      changeOrigin: true,
      xfwd:true,
      ws:true,
      secure:false,
}
这个是代理

请指教,谢谢

阅读 3.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进