API Reference
Socket.IO Client
Client library that connects browsers and Node.js to a Socket.IO server with automatic reconnection and rooms.
Official Documentation ↗CompatibilityThis documentation covers version
v4.7. Check the official docs for the latest API surface.Installation
npm
npm install socket.io-clientMethods
No methods match this filter.
socket.io-client maintains a bidirectional, event-based connection with fallbacks and reconnect logic.
Key Features
- Automatic reconnection with backoff
- Event emit and listener API
- Ack callbacks and binary support
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://socket.io/docs/v4/client-api/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:52:35.217Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- The callback argument is optional and will be called once the attempt fails or succeeds. (https://socket.io/docs/v4/client-api/)
- This attribute can be used after a connection failure: socket . (https://socket.io/docs/v4/client-api/)
FAQ
- How is Socket.IO different from raw WebSocket?
- Socket.IO adds reconnection, acknowledgements, rooms, and an HTTP long-polling fallback on top of WebSocket, which raw sockets do not provide.
- Why is my client not connecting?
- The client and server versions must be compatible, and CORS or a proxy may block the handshake. Check the transport list and server cors config.
- How do I clean up a connection?
- Call socket.disconnect() to close it and remove listeners, or socket.close() to also stop reconnection attempts.
Report a problem with this API docOpens a pre-filled issue on GitHub.