Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot read property 'sid' of undefined socket.io.client

Tags:

socket.io

spfx

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
like image 946
Pratibha Krishnan Avatar asked Dec 31 '22 19:12

Pratibha Krishnan


2 Answers

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

like image 81
mohamed sabith Avatar answered Apr 13 '23 14:04

mohamed sabith


"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.

like image 30
Pratibha Krishnan Avatar answered Apr 13 '23 13:04

Pratibha Krishnan