maximegris / node-websockify

A simple WebSocket-to-TCP proxy/bridge you can use in NodeJS
MIT License
36 stars 17 forks source link

How can i handle multiple connection, with different ip and different ports ? #15

Open emulk opened 3 years ago

emulk commented 3 years ago

I need to handel the connection on different servers, is possible to open different connection, with like 5 different servers, like:

websockifyMaker({ source: '127.0.0.1:8081', target: 'remoteServerIp:5901' }, { source: '127.0.0.1:8082', target: 'remoteServerIp:5902' }, { source: '127.0.0.1:8083', target: 'remoteServerIp:5903' }

);

Thank you

Craigzyc commented 3 years ago

You can just make multiple instances

let websockify = []
websockify[0] = require('@maximegris/node-websockify');
websockify[1] = require('@maximegris/node-websockify');
websockify[2] = require('@maximegris/node-websockify');

websockify[0]({
    source: '127.0.0.1:8081',
    target: 'remoteServerIp:5901'
});

websockify[1]({
    source: '127.0.0.1:8082',
    target: 'remoteServerIp:5902'
});

websockify[2]({
    source: '127.0.0.1:8083',
    target: 'remoteServerIp:5903'
});
sukkamehu commented 3 years ago

@emulk https://github.com/sukkamehu/node-multi-websockify Just moment ago I created probably something which you could utilize?

mirkoboggian commented 1 year ago

You can just make multiple instances

let websockify = []
websockify[0] = require('@maximegris/node-websockify');
websockify[1] = require('@maximegris/node-websockify');
websockify[2] = require('@maximegris/node-websockify');

websockify[0]({
    source: '127.0.0.1:8081',
    target: 'remoteServerIp:5901'
});

websockify[1]({
    source: '127.0.0.1:8082',
    target: 'remoteServerIp:5902'
});

websockify[2]({
    source: '127.0.0.1:8083',
    target: 'remoteServerIp:5903'
});

Hi, it doens't work.

`WebSocket settings:

Error: The HTTP/S server is already being used by another WebSocket server at new WebSocketServer (C:\Websockify\node_modules\ws\lib\websocket-server.js:83:15) at Server. (C:\Websockify\node_modules\@maximegris\node-websockify\websockify.js:199:14) at Object.onceWrapper (node:events:628:28) at Server.emit (node:events:526:35) at emitListeningNT (node:net:1785:10) at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

Node.js v18.17.1`

mirkoboggian commented 1 year ago

I need to handel the connection on different servers, is possible to open different connection, with like 5 different servers, like:

websockifyMaker({ source: '127.0.0.1:8081', target: 'remoteServerIp:5901' }, { source: '127.0.0.1:8082', target: 'remoteServerIp:5902' }, { source: '127.0.0.1:8083', target: 'remoteServerIp:5903' }

);

Thank you

did you solve?