This document describes the 4th version of the Engine.IO protocol.
Table of content
The Engine.IO protocol enables full-duplex and low-overhead communication between a client and a server.
It is based on the WebSocket protocol and uses HTTP long-polling as fallback if the WebSocket connection can't be established.
The reference implementation is written in TypeScript:
The Socket.IO protocol is built on top of these foundations, bringing additional features over the communication channel provided by the Engine.IO protocol.
The connection between an Engine.IO client and an Engine.IO server can be established with:
The HTTP long-polling transport (also simply referred as "polling") consists of successive HTTP requests:
- long-running
GETrequests, for receiving data from the server - short-running
POSTrequests, for sending data to the server
The path of the HTTP requests is /engine.io/ by default.
It might be updated by libraries built on top of the protocol (for example, the Socket.IO protocol uses /socket.io/).
The following query parameters are used:
| Name | Value | Description |
|---|---|---|
EIO |
4 |
Mandatory, the version of the protocol. |
transport |
polling |
Mandatory, the name of the transport. |
sid |
<sid> |
Mandatory once the session is established, the session identifier. |
If a mandatory query parameter is missing, then the server MUST respond with an HTTP 400 error status.
When sending binary data, the sender (client or server) MUST include a Content-Type: application/octet-stream header.
Without an explicit Content-Type header, the receiver SHOULD infer that the data is plaintext.
Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type