Is possible to create a tunnel with ngrok for an ftp server created using a node cli script that runs from localhost?
UPDATE
I'm using this code but not able to start the server and connect
#!/usr/bin/env node
/**
*
*/
const path = require('path');
const ngrok = require('ngrok');
const FtpServer = require('ftp-srv');
const www = path.format({dir: __dirname, base: '/shared'})
const ftpServer = new FtpServer({
url: 'ftp://127.0.0.1:21',
anonymous: true,
greeting: 'Hello user!'
});
ftpServer.on('login', (data, resolve, reject) => {
console.log(data);
resolve({root: www});
});
ftpServer.listen().then( () => {
console.log('Server is running');
ngrok.connect({proto: 'tcp', addr: 21});
});
I get this error
{"name":"ftp-srv","hostname":"host.local","pid":38965,"level":40,"msg":"Passive URL not set. Passive connections not available.","time":"2021-03-07T21:34:50.077Z","v":0}
{"name":"ftp-srv","hostname":"host.local","pid":38965,"level":50,"err":{"message":"listen EACCES: permission denied 127.0.0.1:21","name":"Error","stack":"Error: listen EACCES: permission denied 127.0.0.1:21\n at Server.setupListenHandle [as _listen2] (node:net:1278:21)\n at listenInCluster (node:net:1343:12)\n at doListen (node:net:1480:7)\n at processTicksAndRejections (node:internal/process/task_queues:81:21)","code":"EACCES"},"msg":"[Event] error","time":"2021-03-07T21:34:50.105Z","v":0}
Unhandled rejection Error: listen EACCES: permission denied 127.0.0.1:21
at Server.setupListenHandle [as _listen2] (node:net:1278:21)
at listenInCluster (node:net:1343:12)
at doListen (node:net:1480:7)
at processTicksAndRejections (node:internal/process/task_queues:81:21)
I need to start a node http server first? how I will connect to the tunnel that will have this address tcp://2.tcp.ngrok.io:11653 ?
Error: listen EACCES: permission denied 127.0.0.1:21looks to me that your operating system is not allowing the server to listen on port 21. This is not uncommon. You may need to move it to a different port, like 21021 or whatever - Brettski