socketio / socket.io

Realtime application framework (Node.JS server)
https://socket.io
MIT License
61.04k stars 10.11k forks source link

io.protocol is undefined #5146

Closed Anand-Keshavan closed 4 weeks ago

Anand-Keshavan commented 2 months ago

Describe the bug io.protocol is undefined

To Reproduce

Please fill the following code example:

Socket.IO server version: not relevant

Server

Socket.IO client version: 4.7.5

Client

 import { io } from "socket.io-client";
const revisionNumber = io.protocol;

console.log(`$$$Debug: SocketIo PROTOCOL NUMBER ${revisionNumber}`); --> undefined

Expected behavior expected the socket protocol number. As the python-socketio server returns "The client is using an unsupported version of the Socket.IO or Engine.IO protocols" This is a monrepo with different components using different versions of the socket.io client library. I need to figure out whether the library used by my component follows the correct protocol. It is bad enough that there is no way to know the version of the library programmatically.

Platform:

Additional context Add any other context about the problem here.

darrachequesne commented 2 months ago

The syntax is:

import { protocol } from "socket.io-client";

console.log(protocol); // current is 5

Reference for the Socket.IO protocol: https://github.com/socketio/socket.io/blob/main/docs/socket.io-protocol/v5-current.md

Same with the underlying Engine.IO client:

import { protocol } from "engine.io-client";

console.log(protocol); // current is 4

Reference for the Engine.IO protocol: https://github.com/socketio/socket.io/blob/main/docs/engine.io-protocol/v4-current.md

darrachequesne commented 4 weeks ago

I think this can be closed now. Please reopen if needed.