io.connect()不工作,我不知道是什么问题

mf98qq94  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(268)

[这是Angular 代码][1]这是我的节点js代码

wgx48brx

wgx48brx1#

请复制/粘贴您的实际代码。因此不鼓励截图。
确保在所有i/o操作中都包含错误处理。例如:
https://socket.io/docs/v4/client-initialization/

socket.on("connect_error", (err) => {
  if (err.message === "invalid credentials") {
    socket.auth.token = "efgh";
    socket.connect();
  }
});

... 或
https://developer.mozilla.org/en-us/docs/web/api/websocket/onerror

webSocket.onerror = function(event) {
  console.error("WebSocket error observed:", event);
};

下一步是获取可行的错误消息。
请查看库的文档,以确定捕获和处理特定应用程序错误的“最佳”方法。

相关问题