通过sTunnel向服务器发出请求

我有一个运行在通过sTunnelconfiguration的en EC2实例上的小应用程序。

我的sTunnel是这样configuration的

client = no cert = /etc/stunnel/stunnel.pem key = /etc/stunnel/stunnel.pem [proxy] connect = 127.0.0.1:3000 accept = private_ip:1500 

我的理解是,我可以发送一个请求到private_ip:1500 ,这将切换到本地主机上运行的进程,但是当我尝试发送一些东西到IP地址时,我得到一个ETIMEDOUT错误。

以下是我提出的要求:

 #!/usr/bin/env node var net = require('net'); var HOST = 'private_ip'; var PORT = 1500; var client = new net.Socket(); client.connect(PORT, HOST, function() { console.log('CONNECTED TO: ' + HOST + ':' + PORT); }); // Add a 'data' event handler for the client socket // data is what the server sent to this socket client.on('data', function(data) { console.log('DATA: ' + data); // Close the client socket completely client.destroy(); }); // Add a 'close' event handler for the client socket client.on('close', function() { console.log('Connection closed'); }); 

谁能帮忙?

编辑:

服务器正在监听如下:

 var config = require('./config/config.js'); var net = require('net'); var timer = require('./timer.js'); const server = require('net').createServer({ pauseOnConnect: true }); const child = require('child_process').fork('anotherProcess.js', ['child']); server.on('connection', function(socket) { child.send('socket', socket); }); server.listen(config.proxy.port, function() { console.log((new Date()) + ' Server is listening on port ' + config.proxy.port); }); server.on('error', function(err) { if (err.code === 'EADDRINUSE') { console.log('Address in use, retrying...'); setTimeout(function() { server.close(); server.listen(config.proxy.port); }, 1000); } });