npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

socket.io-client-pro2

v1.0.21

Published

SocketClient is a powerful and flexible Node.js library for interacting with Socket.IO servers. It handles connections, disconnections, and events gracefully, providing advanced configuration options like proxy support, error handling, and SSL/TLS certifi

Readme

SocketClient

SocketClient is a powerful and flexible Node.js library for interacting with Socket.IO servers. It handles connections, disconnections, and events gracefully, providing advanced configuration options like proxy support, error handling, and SSL/TLS certificate management.

Table of Contents

Features

  • Support for Socket.IO versions v2, v3, and v4.
  • Automatic reconnections with configurable retries.
  • Proxy server support for both custom and environment-based proxies.
  • Easy integration of SSL/TLS certificates for secure connections.
  • Custom event listeners for handling socket events.
  • Built-in utilities for managing headers, query parameters, and cookies.

Installation

To install the SocketClient, use npm:

npm install socket.io-client-pro

Usage

Here’s a quick example of how to use the SocketClient:

const { SocketClient } = require('socket.io-client-pro');

const client = new SocketClient({
    target: {
        "project_id": "guest",
        "target_id": "1aaa0cc37a7009",
        "parent_id": "0",
        "target_type": "websocket",
        "name": "ws://localhost:8080/?query1=aaa",
        "sort": 2001,
        "version": 3,
        "mark_id": "1",
        "status": 1,
        "method": "Raw",
        "request": {
            "event": {
                "parameter": [
                    {
                        "description": "自定义 my-event",
                        "is_checked": 1,
                        "key": "custom-event",
                        "value": ""
                    },
                    {
                        "description": "自定义 my-even2",
                        "is_checked": 1,
                        "key": "my-even2",
                        "value": ""
                    }
                ]
            },
            "header": {
                "parameter": [
                    {
                        "description": "",
                        "field_type": "String",
                        "is_checked": 1,
                        "key": "connection",
                        "value": "{{aa}}",
                        "not_null": 1,
                        "param_id": "1aaaac74ba700a"
                    },
                    {
                        "description": "",
                        "field_type": "String",
                        "is_checked": 1,
                        "key": "bbb",
                        "value": "456",
                        "not_null": 1,
                        "param_id": "1aaaadcc3a700b"
                    }
                ]
            },
            "query": {
                "parameter": [
                    {
                        "description": "",
                        "field_type": "String",
                        "is_checked": 1,
                        "key": "query1",
                        "value": "1",
                        "not_null": 1,
                        "param_id": "1aaeb8687a7000"
                    },
                    {
                        "description": "",
                        "field_type": "String",
                        "is_checked": 1,
                        "key": "query2",
                        "value": "哈哈😂",
                        "not_null": 1,
                        "param_id": "1aaebb177a7001"
                    }
                ]
            },
        },
        "url": "http://cc.apipost.cc:6023",
        "config": {
            "information_size": 5,
            "reconnect_num": 0,
            "reconnect_time": 5000,
            "shake_hands_path": "/socket.io",
            "shake_hands_time_out": 0,
            "socket_event_name": "",
            "socketIo_version": "v3"
        },
        "created_at": "2024-12-06T11:38:52+08:00",
        "updated_at": "2024-12-06T11:56:16+08:00"
    },
    option: {
        "globals": {
            "aa": 11
        },
        "env": {
            "env_id": "1",
            "env_name": "默认环境",
            "env_pre_url": "",
            "env_pre_urls": {
                "1": {
                    "server_id": "1",
                    "name": "默认服务",
                    "sort": 1000,
                    "uri": ""
                },
                "default": {
                    "server_id": "1",
                    "name": "默认服务",
                    "sort": 1000,
                    "uri": ""
                }
            },
            "environment": {
                "aa": 22,
                "bb": 33
            }
        },
        "cookies": {
            "switch": 1,
            "data": []
        },
        "system_configs": {
            "send_timeout": 0,
            "auto_redirect": -1,
            "max_redirect_time": 5,
            "auto_gen_mock_url": 1,
            "request_param_auto_json": -1,
            "proxy": {
                "type": 2,
                "envfirst": 1,
                "bypass": [],
                "protocols": [
                    "http"
                ],
                "auth": {
                    "authenticate": -1,
                    "host": "",
                    "username": "",
                    "password": ""
                }
            },
            "ca_cert": {
                "open": -1,
                "path": "",
                "base64": "data:application/json;base64,ewogICAgImNsaWVudE5hbWUiOiAiVGh1bmRlciBDbGllbnQiLAogICAgImNvbGxlY3Rpb25OYW1lIjogIm1tbSIsCiAgICAiY29sbGVjdGlvbklkIjogImY1Zjc0NDBlLTYzMTAtNDcxYS04ZDlmLWYxODkxODUzZGY1NSIsCiAgICAiZGF0ZUV4cG9ydGVkIjogIjIwMjQtMTItMDVUMTc6NTQ6MTEuNjE0WiIsCiAgICAidmVyc2lvbiI6ICIxLjIiLAogICAgImZvbGRlcnMiOiBbXSwKICAgICJyZXF1ZXN0cyI6IFsKICAgICAgICB7CiAgICAgICAgICAgICJfaWQiOiAiNmIxMjgxNGQtNTRkNy00OThkLThlM2MtNTcwMzBkN2Y1ODE3IiwKICAgICAgICAgICAgImNvbElkIjogImY1Zjc0NDBlLTYzMTAtNDcxYS04ZDlmLWYxODkxODUzZGY1NSIsCiAgICAgICAgICAgICJjb250YWluZXJJZCI6ICIiLAogICAgICAgICAgICAibmFtZSI6ICJlY2hvIGFwaSIsCiAgICAgICAgICAgICJ1cmwiOiAiaHR0cHM6Ly93d3cudGh1bmRlcmNsaWVudC5jb20vd2VsY29tZSIsCiAgICAgICAgICAgICJtZXRob2QiOiAiR0VUIiwKICAgICAgICAgICAgInNvcnROdW0iOiAyMDAwMCwKICAgICAgICAgICAgImNyZWF0ZWQiOiAiMjAyNC0wOC0yMFQwNDowMToxMS4zNzNaIiwKICAgICAgICAgICAgIm1vZGlmaWVkIjogIjIwMjQtMDgtMjBUMDQ6MDE6MjkuMTA4WiIsCiAgICAgICAgICAgICJoZWFkZXJzIjogW10KICAgICAgICB9CiAgICBdLAogICAgInJlZiI6ICJNeUhjb1BocWYtVXFFMlpxQ2RSdHNpUFAtUzMzNDVoaDFaRE5tZ0Nscm82SG4zT05uZl8yMWtod2FBUHZHTTNoUERmb3VZLV9BbVhUN0VjOV9Vblh0USIKfQ=="
            },
            "client_cert": {}
        },
        "custom_functions": {}
    },
    callback: (response) => {
        console.log(response);
    }
});

(async () => {
    await client.connect();
    client.emitEvent('message', { text: 'Hello, world!' });
})();

Configuration Options

  • callback: A function that will be called with the response of socket operations.

Event Listeners

You can set up custom event listeners in the request.event:

event: {
    socketIoEventListeners: [
        { key: 'someEvent', is_checked: true },
        { key: 'anotherEvent', is_checked: true },
    ]
}

These events will trigger the callback function you provided during initialization.

Methods

  • connect(): Establish a connection to the Socket.IO server.
  • emitEvent(event, data, ackCallback): Emit an event to the server with optional acknowledgment callback.
  • disconnect(): Disconnect from the Socket.IO server.
  • awaitDisconnect(): Wait for the Socket.IO server to disconnect.

License

This project is licensed under the MIT License.