Leaf
    Preparing search index...
    interface ServerOptions {
        adapter: AdapterConstructor;
        addTrailingSlash?: boolean;
        allowEIO3?: boolean;
        allowRequest?: (
            req: IncomingMessage,
            fn: (err: undefined | null | string, success: boolean) => void,
        ) => void;
        allowUpgrades?: boolean;
        cleanupEmptyChildNamespaces: boolean;
        connectionStateRecovery: {
            maxDisconnectionDuration?: number;
            skipMiddlewares?: boolean;
        };
        connectTimeout: number;
        cookie?: boolean
        | CookieSerializeOptions & { name: string };
        cors?: CorsOptions | CorsOptionsDelegate;
        destroyUpgrade?: boolean;
        destroyUpgradeTimeout?: number;
        httpCompression?: boolean | object;
        initialPacket?: any;
        maxHttpBufferSize?: number;
        parser: any;
        path: string;
        perMessageDeflate?: boolean | object;
        pingInterval?: number;
        pingTimeout?: number;
        serveClient: boolean;
        transports?: Transport[];
        upgradeTimeout?: number;
        wsEngine?: any;
    }

    Hierarchy

    • ServerOptions
    • AttachOptions
      • ServerOptions
    Index

    Properties

    adapter: AdapterConstructor

    the adapter to use

    the in-memory adapter (https://github.com/socketio/socket.io-adapter)
    
    addTrailingSlash?: boolean

    Whether we should add a trailing slash to the request path.

    true
    
    allowEIO3?: boolean

    whether to enable compatibility with Socket.IO v2 clients

    false
    
    allowRequest?: (
        req: IncomingMessage,
        fn: (err: undefined | null | string, success: boolean) => void,
    ) => void

    A function that receives a given handshake or upgrade request as its first parameter, and can decide whether to continue or not. The second argument is a function that needs to be called with the decided information: fn(err, success), where success is a boolean value where false means that the request is rejected, and err is an error code.

    allowUpgrades?: boolean

    whether to allow transport upgrades

    true
    
    cleanupEmptyChildNamespaces: boolean

    Whether to remove child namespaces that have no sockets connected to them

    false
    
    connectionStateRecovery: {
        maxDisconnectionDuration?: number;
        skipMiddlewares?: boolean;
    }

    Whether to enable the recovery of connection state when a client temporarily disconnects.

    The connection state includes the missed packets, the rooms the socket was in and the data attribute.

    Type declaration

    • OptionalmaxDisconnectionDuration?: number

      The backup duration of the sessions and the packets.

      120000 (2 minutes)
      
    • OptionalskipMiddlewares?: boolean

      Whether to skip middlewares upon successful connection state recovery.

      true
      
    connectTimeout: number

    how many ms before a client without namespace is closed

    45000
    
    cookie?: boolean | CookieSerializeOptions & { name: string }

    configuration of the cookie that contains the client sid to send as part of handshake response headers. This cookie might be used for sticky-session. Defaults to not sending any cookie.

    false
    
    cors?: CorsOptions | CorsOptionsDelegate

    the options that will be forwarded to the cors module

    destroyUpgrade?: boolean

    destroy unhandled upgrade requests

    true
    
    destroyUpgradeTimeout?: number

    milliseconds after which unhandled requests are ended

    1000
    
    httpCompression?: boolean | object

    parameters of the http compression for the polling transports (see zlib api docs). Set to false to disable.

    true
    
    initialPacket?: any

    an optional packet which will be concatenated to the handshake packet emitted by Engine.IO.

    maxHttpBufferSize?: number

    how many bytes or characters a message can be, before closing the session (to avoid DoS).

    1e5 (100 KB)
    
    parser: any

    the parser to use

    the default parser (https://github.com/socketio/socket.io-parser)
    
    path: string

    name of the path to capture

    "/socket.io"
    
    perMessageDeflate?: boolean | object

    parameters of the WebSocket permessage-deflate extension (see ws module api docs). Set to false to disable.

    false
    
    pingInterval?: number

    how many ms before sending a new ping packet

    25000
    
    pingTimeout?: number

    how many ms without a pong packet to consider the connection closed

    20000
    
    serveClient: boolean

    whether to serve the client files

    true
    
    transports?: Transport[]

    The low-level transports that are enabled. WebTransport is disabled by default and must be manually enabled:

    new Server({
    transports: ["polling", "websocket", "webtransport"]
    });
    ["polling", "websocket"]
    
    upgradeTimeout?: number

    how many ms before an uncompleted transport upgrade is cancelled

    10000
    
    wsEngine?: any

    what WebSocket server implementation to use. Specified module must conform to the ws interface (see ws module api docs). An alternative c++ addon is also available by installing eiows module.

    require("ws").Server