[Error] Socket.io Version err

김병민·2022년 9월 8일
0

그냥 내 err

목록 보기
12/17
post-thumbnail

Socket.io Version err

error log

err_socket Error: It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible
at Socket.onpacket (socket.js:241)
at Manager.push../node_modules/component-emitter/index.js.Emitter.emit (index.js:140)
at Manager.emitReserved (typed-events.js:71)
at Manager.ondecoded (manager.js:241)
at Decoder.push../node_modules/component-emitter/index.js.Emitter.emit (index.js:140)
at Decoder.add (index.js:141)
at Manager.ondata (manager.js:231)
at Socket.push../node_modules/component-emitter/index.js.Emitter.emit (index.js:140)
at Socket.onPacket (socket.js:357)
at WS.push../node_modules/component-emitter/index.js.Emitter.emit (index.js:140)
at WS.onPacket (transport.js:113)
at WS.onData (transport.js:105)
at WebSocket.ws.onmessage (websocket.js:95)

위 에러는 서버의 Socket IO 버전과 프론트의 버전이 달라서 생기는 오류이다.
( 2.x -> 3.x version )

Solution

매우 간단 둘 중 하나 버전을 바꿔서 설치해주면 끝

주의할 점은 버전이 바뀐만큼 인터넷에서 돌아다니는 Socket io 활용 글을 무작정 따라하면 안된다. 공식 문서에 나오는 마이그레이션 부분을 참고하여 무엇이 사용가능한지를 참고하자

또한 에러는

socket.io("error",(err:Error)=>{
	console.log(err)
})

로 확인하자

profile
I'm beginner

0개의 댓글