ngrok
ngrok copied to clipboard
How can i make a tunnel for mongodb connection?
Currently I have code that look like this.
const dburl = "mongodb://username:password@localhost:27017/test"
const ssh = {
ngrok: (proto, addr) => {
return ngrok.connect({
proto,
addr,
authtoken: config.authtoken
}).then(url => {
console.log('Tunnel Created -> ', url);
logger.info(url);
console.log(`Tunnel Inspector -> http://127.0.0.1:${addr}`);
}).catch(err => {
console.error(err);
})
}
}
ssh.ngrok('tcp', 27017).then(() => connect())
function connect() {
mongoose.connection
.on('error', console.log)
.on('disconnected', connect)
.once('open', () => {
console.log('MongoDB connection active')
var io = require("socket.io")(wsLogServer);
wsLog.connect(io)
});
return mongoose.connect(dburl, { useNewUrlParser: true, useUnifiedTopology: true });
}
The problem is that I keep getting localhost:27017 econn refused. It was working before this now it doesn't. I didn't change any code. Is this the proper way to setup mongodb connection through ngrok?
What'd you end up doing?
Nothing mann. Still unresolved