4

I am using socket.io.client in a spfx react app and getting this error while doing the socket connection:

Uncaught TypeError: Cannot read property 'sid' of undefined
leonheess
  • 16,068
  • 14
  • 77
  • 112

2 Answers2

5

Make sure you have same version of socket.io in both server side and client side. Because socket.io 2.0 is no longer compatible with 3.0. you can check it in their api docs https://socket.io/docs/v3/migrating-from-2-x-to-3-0/index.html

  • yes is correct way for fix, you have to update your socket.io front and back packages otherwise you will have malfunctions for the way of transporting the socket, the front will use polling and therefore you will have mass socket disconnection connections.... Solution: update the versions of your socket.io packages front and back – Canonne Gregory Nov 21 '20 at 03:19
4

"socket.io-client": "^3.0.1" has this issue. it is the latest released version.

On downgrading the version to "socket.io-client": "^2.3.1" the issue got resolved.