🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

proxy-websocket

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-websocket

An easy way to connect to websockets with HTTP/HTTPS proxies.

1.0.2
latest
npm
Version published
Maintainers
1
Created
Source

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:

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

Keywords

websockets

FAQs

Package last updated on 03 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts