proxy-websocket

1.0.2 • Public • Published

Proxy-Websocket

proxy-websocket provides an easy way to connect to websockets with HTTP/HTTPS proxies.

Installation

You can install proxy-websocket via npm:

npm install proxy-websocket

Example

const proxyToWs = require('proxy-websocket');

const socket = proxyToWs('wss://echo.websocket.org/', 'http://154.202.103.5:3128');

socket.on('open', () => {
    console.log('WebSocket connection opened');
});

socket.on('message', (data) => {
    const message = Buffer.from(data).toString('utf8');
    console.log('Received message:', message);
});

socket.on('close', () => {
    console.log('WebSocket connection closed');
});

Usage

The proxyToWs function takes two arguments:

  1. The URL of the WebSocket server you want to connect to.
  2. The URL of the HTTP/HTTPS proxy you want to use.
const socket = proxyToWs(websocketServerUrl, httpProxyUrl);

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    5
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    5

Package Sidebar

Install

npm i proxy-websocket

Weekly Downloads

5

Version

1.0.2

License

ISC

Unpacked Size

3.29 kB

Total Files

3

Last publish

Collaborators

  • amysox.