The socket.io-client background message contains a disconnection in Chinese. Has anyone encountered it?

in the actual project, this is the first time that the connection is broken when receiving a message containing Chinese, and it is normal after reconnection. In order to ask a question, I extracted the relevant code and found that the front end kept reporting errors as soon as it received the message in Chinese.
server

import http from "http";
import socket from "socket.io";

const server = http.createServer();
const io = socket(server);

io.on("connection", (client) => {
  console.log("SOCKET->connection:" + client.id);
  client.on("message", async function (message) {
    console.log(message);
    client.send({message: "success"})
  });

  client.on("disconnect", async function () {
    console.log("SOCKET->disconnect:" + client.id);
  });
});

server.listen(3001);

console.log("server running http://localhost:3001");

client

import io from "socket.io-client";

const socket = io("ws://localhost:3001");

socket.on("connect", () => {
  console.log("connect");
  socket.send({message: "hello"})
});

socket.on("disconnect", () => {
  console.log("disconnect")
});

socket.on("error", err => {
  console.log(err)
});

socket.on("message", res => {
  console.log(res)
});

now the English message is normal
![![][2]][1]





socket.io socket.io-client
have all been upgraded to 2.1.1
does any god know why


I see issue, issue in socket.io, but there is no good solution.
it is recommended to send and receive via encoding and decoding, or through buffer


.

I have been looking for the cause of this problem since I found it in the morning. As a result, I have just tried to quote it with a traditional tag

.
<script type=text/javascript src=//cdn.bootcss.com/socket.io/2.1.1/socket.io.js></script>

I can't believe I made a mistake. I'm really quite speechless. I've been wasting my whole day on this

.
Menu