[Error] Cannot read property 'sid' of undefined
See original GitHub issueHi! I migrated to the latest version 3.0.3. But on the client-side, I’m getting this error immediately after connecting:
error
socket.js:189 Uncaught TypeError: Cannot read property 'sid' of undefined
at Socket.onpacket (socket.js:189)
at Manager.<anonymous> (index.js:21)
at Manager../node_modules/component-emitter/index.js.Emitter.emit (index.js:145)
at Manager.ondecoded (manager.js:209)
at Decoder.<anonymous> (index.js:21)
at Decoder../node_modules/component-emitter/index.js.Emitter.emit (index.js:145)
at Decoder.add (index.js:117)
at Manager.ondata (manager.js:201)
at Socket.<anonymous> (index.js:21)
at Socket../node_modules/component-emitter/index.js.Emitter.emit (index.js:145)
client-side
const options = {
path: '/ws',
query: { accessToken: 'XXXX', id: 'XXXXXX' },
transports: ['websocket']
};
const socket = io("http://localhost:3030/my-namespace", options);
socket.on("connection:error", payload => console.log(payload)); // <-- This not listen but received (Network Tab)
socket.on("disconnect", reason => console.log(reason)); // <-- This works
server-side
const options = {
pingTimeout: 5000,
pingInterval: 5000,
path: '/ws/'
};
const server = require('http').createServer();
const io = require('socket.io')(server, options);
server.listen(3000);
Related question: https://stackoverflow.com/questions/64785024/uncaught-typeerror-cannot-read-property-sid-of-undefined-socket-io-client
What I’m doing wrong? Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
TypeError: Cannot read property 'sid' of undefined
The callback of client.messages.create is used as }, function(err, message) { console.log(message.sid); });. When there will be error, the first parameter ...
Read more >Cannot read properties of undefined (reading 'id') - TrackJS
This error can be thrown for a lot of reasons, as it is not uncommon to look for the id property of an...
Read more >Error and Warning Dictionary | Twilio
Below is a full list of all possible Twilio REST API error codes. Read our guidance on debugging your Twilio application for general...
Read more >Collada Importer cannot read property sid of undefined
So in my console i get the error: “Cannot read property sid of undefined” because the collada loader is unable to get the...
Read more >Cannot read property 'sid' of undefined socket.io-client
I'm getting the same error when using last version of socket.io-client on Node.js. If I use an older version like v2.3.0 I don't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It seems you are using a v3 client with a v2 server, which are not compatible. Could you please check?
For future readers: this issue happened when one tries to reach a v2 Socket.IO server with a v3 client (which is not possible due to incompatible exchange protocols). We have added a check for that case (https://github.com/socketio/socket.io-client/commit/ec1f8c3474b54600420487a0554cb195cc78f2bc), so this issue should be fixed.
In order to upgrade an existing deployment, please see https://socket.io/docs/v3/migrating-from-2-x-to-3-0/#How-to-upgrade-an-existing-production-deployment