sip
socket.io-proxy-134
npm i socket.io-proxy-134
sip

socket.io-proxy-134

A socket.io client for node.js that can connect through a proxy server.

by Stephan Brenner

1.0.4 (see all)License:MITTypeScript:Not Found
npm i socket.io-proxy-134
Readme

socket.io-proxy

A socket.io client for node.js that can connect through a proxy server.

Build Status

Installation

$ npm install socket.io-proxy

How to use

Based on environment variable

socket.io-proxy will automatically apply the proxy settings based on the http_proxy environment variable. If no proxy is defined, a direct connection to the destination will be established.

var proxy = require('socket.io-proxy');

var socket = proxy.connect('http://destination');

socket.on('connect', function () {
    console.log('Socket connected');
    socket.on('command', function (data) {
        console.log('Received data');
    });
    socket.on('disconnect', function() {
        console.log('Socket disconnected');
    });
});

On Linux you can specify the environment variable in the following way: export http_proxy=http://proxy:8080

On Windows: set HTTP_PROXY=http://proxy:8080

Explicit proxy definition

You can also directly specify the proxy server using the init function.

var proxy = require('socket.io-proxy');

proxy.init('http://proxy:8080');
var socket = proxy.connect('http://destination');

socket.on('connect', function () {
    console.log('Socket connected');
    socket.on('command', function (data) {
        console.log('Received data');
    });
    socket.on('disconnect', function() {
        console.log('Socket disconnected');
    });
});

Downloads/wk

2

GitHub Stars

28

LAST COMMIT

5yrs ago

MAINTAINERS

1

CONTRIBUTORS

9

OPEN ISSUES

7

OPEN PRs

1
VersionTagPublished
1.0.4
latest
7yrs ago
No alternatives found
No tutorials found
Add a tutorial