socket.idsocket.connected// either by directly modifying the `auth` attribute
socket.on("connect_error", () => {
socket.auth.token = "abcd";
socket.connect();
});
// or if the `auth` attribute is a function
const socket = io({
auth: (cb) => {
cb(localStorage.getItem("token"));
}
});
socket.on("connect_error", () => {
setTimeout(() => {
socket.connect();
}, 1000);
});
io server disconnect : 서버에서 강제적으로 서버 소켓의 연결을 끊은 경우 = socket.disconnect()을 호출한 경우io client disconnect : 클라이언트에서 수동으로 서버 소켓의 연결을 끊은 경우 = socket.disconnect()을 호출한 경우ping timeout : 서버가 ping timeout 이내에 응답하지 않은 경우transport close : 연결이 닫힌 경우 (ex. 사용자가 연결을 유실하거나, wifi에서 4g로의 네트워크 변경이 일어난 경우 )transport error : 연결 중 에러가 발생한 경우 (ex. HTTP long polling 사이클에서 서버가 죽은 경우 )disconnecting, newListener, removeListener 와 같은 이벤트는 특별한 이벤트 이기 때문에 우리가 애플리케이션에서 사용하면 안된다.