Skip to content

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

License

Notifications You must be signed in to change notification settings

csandanov/socket.io-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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');
    });
});

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%