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 🙏

© 2026 – Pkg Stats / Ryan Hefner

multiplex-tunnel-transport

v1.4.0

Published

tcp/http tunnel with multiplexed transport (wsmux + tlsmux)

Downloads

316

Readme

multiplex-tunnel-transport

A TCP/HTTP reverse-tunnel with stream multiplexing: a single persistent connection between the client (behind NAT) and the server (public), carrying many logical streams — one per inbound HTTP request. No socket pool, no per-request dial-back, no NAT re-traversal.

Two transports ship behind a shared interface, selectable via config:

  • wsmux (default) — frames over the existing socket.io control channel. No extra ports. Works through any HTTP-only proxy.
  • yamux — a yamux-style binary mux over one persistent TLS connection on the agent port. Lower overhead, real per-stream credit-window backpressure.

Install

npm install multiplex-tunnel-transport

Usage

Server (public, in front of the tunnel)

import { TunnelServer } from 'multiplex-tunnel-transport';

const server = new TunnelServer({
  serverPrivateKey: '/path/to/server.key',
  serverPublicKey: '/path/to/server.crt',
  httpsPrivateKey: '/path/to/https.key',
  httpsPublicKey: '/path/to/https.crt',
  transport: 'wsmux', // or 'yamux'
});

server.open();
// HTTPS listens on :4000 (public). For yamux, an additional TLS data
// channel listens on :4001.

Client (behind NAT, forwards to a local service)

import { TunnelManager } from 'multiplex-tunnel-transport';

const manager = new TunnelManager({
  remoteUrl: 'https://your-server.example.com:4000/',
  serverPrivateKey: '/path/to/server.key',
  serverPublicKey: '/path/to/server.crt',
  localPort: 3001, // local service to forward tunneled requests to
});

manager.open();

The server tells the client which transport to use during the socket.io handshake — clients don't configure this themselves.

Architecture

                              ┌────────────────────────┐
   public HTTPS request ──▶  │      TunnelServer      │
   (e.g. curl :4000)          │  - HTTPS :4000         │
                              │  - socket.io control   │
                              │  - TLS agent :4001     │
                              │    (yamux only)        │
                              └─────────┬──────────────┘
                                        │
                          one persistent multiplexed
                          connection (wsmux or tlsmux)
                                        │
                              ┌─────────▼──────────────┐
                              │      TunnelClient      │
                              │  - opens N streams     │
                              │  - pipes each to       │
                              │    localhost:<port>    │
                              └────────────────────────┘

Each public HTTP request → one logical mux stream → bridged to the local service. Backpressure is per-stream (credit window, default 1 MiB).

Configuration

| Field | Where | Default | Description | | -------------------------------------- | ------ | -------------------- | ---------------------------------------------------------------------------- | | transport | server | 'wsmux' | 'wsmux' (frames over socket.io) or 'yamux' (binary mux over TLS). | | localPort | client | 3001 | Local TCP port to forward tunneled requests to. | | serverPrivateKey / serverPublicKey | both | — | RSA keypair used for JWT auth on the control channel and (yamux) TLS. | | httpsPrivateKey / httpsPublicKey | server | — | TLS keypair for the public HTTPS server. | | socketio | both | see below | Pass-through to the underlying socket.io Server / socket.io-client. User values override the package defaults. |

Tuning socket.io

Both TunnelServer and TunnelManager accept a socketio option that's forwarded directly to the socket.io constructor — full type-safety via Partial<ServerOptions> (server) and Partial<ManagerOptions & SocketOptions> (client).

Client defaults (override any of these via socketio):

| Option | Default | Notes | | ------------------------- | ----------- | ------------------------------------------ | | reconnection | true | | | reconnectionAttempts | Infinity | retry forever — set a number to cap | | reconnectionDelay | 1000 | initial backoff (ms) | | reconnectionDelayMax | 10000 | max backoff (ms) | | timeout | 20000 | connect timeout (ms) | | transports | ['websocket'] | |

new TunnelManager({
  remoteUrl: 'https://...',
  serverPrivateKey, serverPublicKey,
  socketio: {
    reconnectionAttempts: 5,   // give up after 5 attempts instead of forever
    reconnectionDelayMax: 30000,
    timeout: 30000,
  },
});

The Authorization: Bearer <jwt> header is set internally and cannot be overridden — any extraHeaders you supply are merged with it.

Server defaults: cors: { origin: '*' }. Override or add anything socket.io's Server accepts:

new TunnelServer({
  serverPrivateKey, serverPublicKey,
  httpsPrivateKey, httpsPublicKey,
  socketio: {
    cors: { origin: 'https://my-app.com' },
    pingInterval: 25000,
    pingTimeout: 60000,
    maxHttpBufferSize: 5_000_000,
  },
});

License

Apache 2.0