luigiplr / node-openvpn

Communicate with a openvpn instance via telnet.
131 stars 26 forks source link

Error while connecting #9

Open computerlearning opened 7 years ago

computerlearning commented 7 years ago

When I'm using this code

var openvpnmanager = require('node-openvpn')
var openvpnBin = require('openvpn-bin')
var path = require('path')

openvpnBin.initialize('openvpn', {
  host: '(VPNServerIP)',
  port: 1194,
  config: path.normalize('config.ovpn')
}).then(function() {
  var managerInstance = openvpnmanager.connect({ host: '(VPNServerIP)', port: 1194 })

  managerInstance.on('connected', function() {
    managerInstance.authorize({
      user: 'username',
      pass: 'password'
    })
  })

  managerInstance.on('console-output', function(output) {
    console.log(output)
  })
})

I am getting these errors

Uncaught Error: Uncaught, unspecified "error" event. (Cannot connect)
    at Telnet.emit (events.js:163)
    at Socket.<anonymous> (/Users/MyName/Desktop/VPN/node_modules/telnet-client/lib/telnet-client.js:52)
    at Object.onceWrapper (events.js:290)
    at emitNone (events.js:86)
    at Socket.emit (events.js:185)
    at Socket._onTimeout (net.js:342)
    at ontimeout (timers.js:365)
    at tryOnTimeout (timers.js:237)
    at Timer.listOnTimeout (timers.js:207)
Uncaught Error: connect ECONNREFUSED (VPNServerIP):1194
    at Object.exports._errnoException (util.js:1022)
    at exports._exceptionWithHostPort (util.js:1045)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090)

Also in terminal after I enter my password on the popup while trying to connect to the server I am getting these errors.

Unhandled rejection TypeError: managerInstance.authorize is not a function
    at EventEmitter.<anonymous> (file:///Users/myname/Desktop/VPN/openVPN.js:15:21)
    at emitNone (events.js:86:13)
    at EventEmitter.emit (events.js:185:7)
    at /Users/myname/Desktop/VPN/node_modules/node-openvpn/lib/openvpn.js:26:28
    at tryCatcher (/Users/myname/Desktop/VPN/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/Users/myname/Desktop/VPN/node_modules/bluebird/js/main/promise.js:510:31)
    at Promise._settlePromiseAt (/Users/myname/Desktop/VPN/node_modules/bluebird/js/main/promise.js:584:18)
    at Promise._settlePromises (/Users/myname/Desktop/VPN/node_modules/bluebird/js/main/promise.js:700:14)
    at Async._drainQueue (/Users/myname/Desktop/VPN/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/Users/myname/Desktop/VPN/node_modules/bluebird/js/main/async.js:133:10)
    at MutationObserver.Async.drainQueues (/Users/myname/Desktop/VPN/node_modules/bluebird/js/main/async.js:15:14)

Any ideas on how I would go about fixing these issues? Thanks!

Currently I'm just using a button that calls a function that includes the code above. I'm new to node.js and electron.js so if it is something stupid I'm sorry. I think the problem is with the line that has managerInstance.authorize, maybe I messed up installing the packages?

Dominic-Preap commented 7 years ago

@luigiplr I also got that problems as well. Any ideas?

mamged commented 7 years ago

++

Hongdeshuai commented 5 years ago

The same problem here. Is anyone can answer this problem?

Hongdeshuai commented 5 years ago

bugsnag.js:616 Error: connect ECONNREFUSED 127.0.0.1:1337 at Object.exports._errnoException (util.js:1024) at exports._exceptionWithHostPort (util.js:1047) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1150)

This is the error message I have. Please help me.

saeidfiy commented 4 years ago

bugsnag.js:616 Error: connect ECONNREFUSED 127.0.0.1:1337 at Object.exports._errnoException (util.js:1024) at exports._exceptionWithHostPort (util.js:1047) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1150)

This is the error message I have. Please help me.

i have that error too,any body know why?

dionsyran2 commented 3 years ago

have you made an account etc.?

rs181915 commented 2 years ago

hi did anyone find the solution for that ???

julekgwa commented 1 year ago

It's a typo

const openvpnBin = require('./openvpn-bin');
const path = require('path');

openvpnBin
  .initialize('openvpn', {
    host: '127.0.0.1',
    port: 1337,
    config: path.normalize('/Users/junius/Downloads/electron/VPN App 2/se.gothenburg.ovpn.com.ovpn'),
  })
  .then(function () {
    const managerInstance = openvpnmanager.connect({
      host: '127.0.0.1',
      port: 1337,
    });

    managerInstance.on('connected', function () {
      openvpnmanager.authorize({
        user: 'juniusl',
        pass: 'Ican@vpn',
      });
    });

    managerInstance.on('console-output', function (output) {
      console.log(output);
    });
  });