• Version 6.5.3
  • Published
  • 717 kB
  • 5 dependencies
  • MIT license


npm i engine.io-client
yarn add engine.io-client
pnpm add engine.io-client


Client for the realtime Engine



variable protocol

const protocol: number;

    variable transports

    const transports: {
    websocket: typeof WS;
    webtransport: typeof WT;
    polling: typeof Polling;


      function installTimerFunctions

      installTimerFunctions: (obj: any, opts: any) => void;

        function nextTick

        nextTick: (callback: Function, ...args: any[]) => void;

          function parse

          parse: (str: string) => any;


            class Socket

            class Socket extends Emitter<
            Record<never, never>,
            Record<never, never>,
            > {}


              constructor(uri: any, opts?: Partial<SocketOptions>);
              • Socket constructor.

                Parameter uri

                uri or options

                Parameter opts


              property binaryType

              binaryType: BinaryType;

                property id

                id: string;

                  property priorWebsocketSuccess

                  static priorWebsocketSuccess: boolean;

                    property protocol

                    static protocol: number;

                      property readyState

                      readyState: SocketState;

                        property transport

                        transport: Transport;

                          property writeBuffer

                          writeBuffer: Packet[];

                            method close

                            close: () => this;
                            • Closes the connection.

                            method send

                            send: (msg: RawData, options?: any, fn?: any) => this;

                              method write

                              write: (msg: RawData, options?: any, fn?: any) => this;
                              • Sends a message.

                                Parameter msg



                                {Object} options.

                                Parameter callback

                                function. {Socket} for chaining.

                              class Transport

                              abstract class Transport extends Emitter<
                              Record<never, never>,
                              Record<never, never>,
                              > {}


                                constructor(opts: any);
                                • Transport abstract constructor.

                                  Parameter opts


                                property name

                                readonly name: string;
                                • The name of the transport

                                property opts

                                protected opts: SocketOptions;

                                  property query

                                  query: Record<string, string>;

                                    property readyState

                                    protected readyState: TransportState;

                                      property setTimeoutFn

                                      protected setTimeoutFn: (
                                      handler: TimerHandler,
                                      timeout?: number,
                                      ...arguments: any[]
                                      ) => number;

                                        property socket

                                        protected socket: any;

                                          property supportsBinary

                                          protected supportsBinary: boolean;

                                            property writable

                                            writable: boolean;

                                              method close

                                              close: () => this;
                                              • Closes the transport.

                                              method createUri

                                              protected createUri: (schema: string, query?: Record<string, unknown>) => string;

                                                method doClose

                                                protected abstract doClose: () => any;

                                                  method doOpen

                                                  protected abstract doOpen: () => any;

                                                    method onClose

                                                    protected onClose: (details?: CloseDetails) => void;
                                                    • Called upon close.

                                                    method onData

                                                    protected onData: (data: RawData) => void;
                                                    • Called with data.

                                                      Parameter data

                                                    method onError

                                                    protected onError: (reason: string, description: any, context?: any) => this;
                                                    • Emits an error.

                                                      Parameter reason

                                                      Parameter description

                                                      Parameter context

                                                      the error context {Transport} for chaining

                                                    method onOpen

                                                    protected onOpen: () => void;
                                                    • Called upon open

                                                    method onPacket

                                                    protected onPacket: (packet: Packet) => void;
                                                    • Called with a decoded packet.

                                                    method open

                                                    open: () => this;
                                                    • Opens the transport.

                                                    method pause

                                                    pause: (onPause: () => void) => void;
                                                    • Pauses the transport, in order not to lose packets during an upgrade.

                                                      Parameter onPause

                                                    method send

                                                    send: (packets: any) => void;
                                                    • Sends multiple packets.

                                                      Parameter packets

                                                    method write

                                                    protected abstract write: (packets: Packet[]) => any;

                                                      class TransportError

                                                      class TransportError extends Error {}


                                                        constructor(reason: string, description: any, context: any);

                                                          property context

                                                          readonly context: any;

                                                            property description

                                                            readonly description: any;

                                                              property type

                                                              readonly type: string;


                                                                interface SocketOptions

                                                                interface SocketOptions {}

                                                                  property addTrailingSlash

                                                                  addTrailingSlash: boolean;
                                                                  • Whether we should add a trailing slash to the request path. true

                                                                  property agent

                                                                  agent: string | boolean;
                                                                  • http.Agent to use, defaults to false (NodeJS only)

                                                                    Note: the type should be "undefined | http.Agent | https.Agent | false", but this would break browser-only clients.

                                                                    See Also

                                                                    • https://nodejs.org/api/http.html#httprequestoptions-callback

                                                                  property autoUnref

                                                                  autoUnref: boolean;
                                                                  • weather we should unref the reconnect timer when it is create automatically false

                                                                  property ca

                                                                  ca: string | string[];
                                                                  • (SSL) An authority certificate or array of authority certificates to check the remote host against.. Can be used in Node.js client environment to manually specify certificate information.

                                                                  property cert

                                                                  cert: string;
                                                                  • (SSL) Public x509 certificate to use. Can be used in Node.js client environment to manually specify certificate information.

                                                                  property ciphers

                                                                  ciphers: string;
                                                                  • (SSL) A string describing the ciphers to use or exclude. Consult the [cipher format list] (http://www.openssl.org/docs/apps/ciphers.html#CIPHER_LIST_FORMAT) for details on the format.. Can be used in Node.js client environment to manually specify certificate information.

                                                                  property closeOnBeforeunload

                                                                  closeOnBeforeunload: boolean;
                                                                  • Whether to automatically close the connection whenever the beforeunload event is received. false

                                                                  property extraHeaders

                                                                  extraHeaders?: {
                                                                  [header: string]: string;
                                                                  • Headers that will be passed for each request to the server (via xhr-polling and via websockets). These values then can be used during handshake or for special proxies.

                                                                  property forceBase64

                                                                  forceBase64: boolean;
                                                                  • Forces base 64 encoding for polling transport even when XHR2 responseType is available and WebSocket even if the used standard supports binary.

                                                                  property host

                                                                  host: string;
                                                                  • The host that we're connecting to. Set from the URI passed when connecting

                                                                  property hostname

                                                                  hostname: string;
                                                                  • The hostname for our connection. Set from the URI passed when connecting

                                                                  property key

                                                                  key: string;
                                                                  • (SSL) Private key to use for SSL. Can be used in Node.js client environment to manually specify certificate information.

                                                                  property onlyBinaryUpgrades

                                                                  onlyBinaryUpgrades: boolean;
                                                                  • Are we only interested in transports that support binary?

                                                                  property passphrase

                                                                  passphrase: string;
                                                                  • (SSL) A string or passphrase for the private key or pfx. Can be used in Node.js client environment to manually specify certificate information.

                                                                  property path

                                                                  path: string;
                                                                  • The path to get our client file from, in the case of the server serving it '/engine.io'

                                                                  property perMessageDeflate

                                                                  perMessageDeflate: {
                                                                  threshold: number;
                                                                  • parameters of the WebSocket permessage-deflate extension (see ws module api docs). Set to false to disable. false

                                                                  property pfx

                                                                  pfx: string;
                                                                  • (SSL) Certificate, Private key and CA certificates to use for SSL. Can be used in Node.js client environment to manually specify certificate information.

                                                                  property port

                                                                  port: string | number;
                                                                  • The port for our connection. Set from the URI passed when connecting

                                                                  property protocols

                                                                  protocols: string | string[];
                                                                  • Either a single protocol string or an array of protocol strings. These strings are used to indicate sub-protocols, so that a single server can implement multiple WebSocket sub-protocols (for example, you might want one server to be able to handle different types of interactions depending on the specified protocol) []

                                                                  property query

                                                                  query: {
                                                                  [key: string]: any;
                                                                  • Any query parameters in our uri. Set from the URI passed when connecting

                                                                  property rejectUnauthorized

                                                                  rejectUnauthorized: boolean;
                                                                  • (SSL) If true, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Can be used in Node.js client environment to manually specify certificate information.

                                                                  property rememberUpgrade

                                                                  rememberUpgrade: boolean;
                                                                  • If true and if the previous websocket connection to the server succeeded, the connection attempt will bypass the normal upgrade process and will initially try websocket. A connection attempt following a transport error will use the normal upgrade process. It is recommended you turn this on only when using SSL/TLS connections, or if you know that your network does not block websockets. false

                                                                  property requestTimeout

                                                                  requestTimeout: number;
                                                                  • Timeout for xhr-polling requests in milliseconds (0) (only for polling transport)

                                                                  property secure

                                                                  secure: boolean;
                                                                  • If this is a secure connection. Set from the URI passed when connecting

                                                                  property timestampParam

                                                                  timestampParam: string;
                                                                  • The param name to use as our timestamp key 't'

                                                                  property timestampRequests

                                                                  timestampRequests: boolean;
                                                                  • Whether to add the timestamp with each transport request. Note: this is ignored if the browser is IE or Android, in which case requests are always stamped false

                                                                  property transportOptions

                                                                  transportOptions: Object;
                                                                  • Transport options for Node.js client (headers etc)

                                                                  property transports

                                                                  transports: string[];
                                                                  • A list of transports to try (in order). Engine.io always attempts to connect directly with the first one, provided the feature detection test for it passes.

                                                                    ['polling','websocket', 'webtransport']

                                                                  property upgrade

                                                                  upgrade: boolean;
                                                                  • Whether the client should try to upgrade the transport from long-polling to something better. true

                                                                  property useNativeTimers

                                                                  useNativeTimers: boolean;
                                                                  • Whether to always use the native timeouts. This allows the client to reconnect when the native timeout functions are overridden, such as when mock clocks are installed. false

                                                                  property withCredentials

                                                                  withCredentials: boolean;
                                                                  • Whether to include credentials (cookies, authorization headers, TLS client certificates, etc.) with cross-origin XHR polling requests false

                                                                  Package Files (7)

                                                                  Dependencies (5)

                                                                  Dev Dependencies (29)

                                                                  Peer Dependencies (0)

                                                                  No peer dependencies.


                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/engine.io-client.

                                                                  • Markdown
                                                                  • HTML
                                                                    <a href="https://www.jsdocs.io/package/engine.io-client"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>